1UNEXPAND(1P)               POSIX Programmer's Manual              UNEXPAND(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       unexpand — convert spaces to tabs
14

SYNOPSIS

16       unexpand [−a|−t tablist] [file...]
17

DESCRIPTION

19       The unexpand utility shall copy files or  standard  input  to  standard
20       output,  converting  <blank>  characters  at the beginning of each line
21       into the maximum number of <tab> characters  followed  by  the  minimum
22       number  of  <space> characters needed to fill the same column positions
23       originally filled by the translated  <blank>  characters.  By  default,
24       tabstops shall be set at every eighth column position. Each <backspace>
25       shall be copied to the output, and  shall  cause  the  column  position
26       count  for tab calculations to be decremented; the count shall never be
27       decremented to a value less than one.
28

OPTIONS

30       The unexpand utility shall conform to the Base  Definitions  volume  of
31       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
32
33       The following options shall be supported:
34
35       −a        In  addition  to translating <blank> characters at the begin‐
36                 ning of each line, translate all sequences  of  two  or  more
37                 <blank>  characters  immediately  preceding a tab stop to the
38                 maximum number of <tab> characters followed  by  the  minimum
39                 number  of  <space> characters needed to fill the same column
40                 positions originally filled by the translated <blank> charac‐
41                 ters.
42
43       −t tablist
44                 Specify  the tab stops. The application shall ensure that the
45                 tablist option-argument is a single argument consisting of  a
46                 single  positive decimal integer or multiple positive decimal
47                 integers, separated by  <blank>  or  <comma>  characters,  in
48                 ascending  order.  If a single number is given, tabs shall be
49                 set tablist column positions apart instead of the default  8.
50                 If multiple numbers are given, the tabs shall be set at those
51                 specific column positions.
52
53                 The application shall ensure that each tab-stop position N is
54                 an  integer value greater than zero, and the list shall be in
55                 strictly ascending order. This is taken to  mean  that,  from
56                 the  start  of  a line of output, tabbing to position N shall
57                 cause the next character output to be in the  (N+1)th  column
58                 position  on  that line. When the −t option is not specified,
59                 the default  shall  be  the  equivalent  of  specifying  −t 8
60                 (except for the interaction with −a, described below).
61
62                 No <space>-to-<tab> conversions shall occur for characters at
63                 positions beyond the last of those specified  in  a  multiple
64                 tab-stop list.
65
66                 When  −t  is  specified,  the  presence  or absence of the −a
67                 option shall be ignored; conversion shall not be  limited  to
68                 the processing of leading <blank> characters.
69

OPERANDS

71       The following operand shall be supported:
72
73       file      A pathname of a text file to be used as input.
74

STDIN

76       See the INPUT FILES section.
77

INPUT FILES

79       The input files shall be text files.
80

ENVIRONMENT VARIABLES

82       The following environment variables shall affect the execution of unex‐
83       pand:
84
85       LANG      Provide a default value for  the  internationalization  vari‐
86                 ables  that are unset or null. (See the Base Definitions vol‐
87                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
88                 ables  for  the  precedence of internationalization variables
89                 used to determine the values of locale categories.)
90
91       LC_ALL    If set to a non-empty string value, override  the  values  of
92                 all the other internationalization variables.
93
94       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
95                 bytes of text data as characters (for example, single-byte as
96                 opposed  to  multi-byte  characters  in  arguments  and input
97                 files), the processing of <tab> and <space>  characters,  and
98                 for  the  determination of the width in column positions each
99                 character would occupy on an output device.
100
101       LC_MESSAGES
102                 Determine the locale that should be used to affect the format
103                 and  contents  of  diagnostic  messages  written  to standard
104                 error.
105
106       NLSPATH   Determine the location of message catalogs for the processing
107                 of LC_MESSAGES.
108

ASYNCHRONOUS EVENTS

110       Default.
111

STDOUT

113       The  standard  output  shall  be equivalent to the input files with the
114       specified <space>-to-<tab> conversions.
115

STDERR

117       The standard error shall be used only for diagnostic messages.
118

OUTPUT FILES

120       None.
121

EXTENDED DESCRIPTION

123       None.
124

EXIT STATUS

126       The following exit values shall be returned:
127
128        0    Successful completion.
129
130       >0    An error occurred.
131

CONSEQUENCES OF ERRORS

133       Default.
134
135       The following sections are informative.
136

APPLICATION USAGE

138       One non-intuitive aspect of unexpand  is  its  restriction  to  leading
139       <space>  characters  when  neither  −a  nor  −t is specified. Users who
140       always want to convert all <space> characters  in  a  file  can  easily
141       alias unexpand to use the −a or −t 8 option.
142

EXAMPLES

144       None.
145

RATIONALE

147       On  several occasions, consideration was given to adding a −t option to
148       the unexpand utility to complement the −t in expand (see expand).   The
149       historical intent of unexpand was to translate multiple <blank> charac‐
150       ters into tab stops, where tab stops were a multiple  of  eight  column
151       positions on most UNIX systems. An early proposal omitted −t because it
152       seemed outside the scope of the User Portability Utilities  option;  it
153       was  not  described  in any of the base documents. However, hard-coding
154       tab stops every eight columns was not suitable  for  the  international
155       community  and broke historical precedents for some vendors in the FOR‐
156       TRAN community, so −t was restored in  conjunction  with  the  list  of
157       valid extension categories considered by the standard developers. Thus,
158       unexpand is now the logical converse of expand.
159

FUTURE DIRECTIONS

161       None.
162

SEE ALSO

164       expand, tabs
165
166       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
167       Variables, Section 12.2, Utility Syntax Guidelines
168
170       Portions  of  this text are reprinted and reproduced in electronic form
171       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
172       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
173       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
174       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
175       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
176       event of any discrepancy between this version and the original IEEE and
177       The Open Group Standard, the original IEEE and The Open Group  Standard
178       is  the  referee document. The original Standard can be obtained online
179       at http://www.unix.org/online.html .
180
181       Any typographical or formatting errors that appear  in  this  page  are
182       most likely to have been introduced during the conversion of the source
183       files to man page format. To report such errors,  see  https://www.ker
184       nel.org/doc/man-pages/reporting_bugs.html .
185
186
187
188IEEE/The Open Group                  2013                         UNEXPAND(1P)
Impressum