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

NAME

12       unexpand — convert spaces to tabs
13

SYNOPSIS

15       unexpand [-a|-t tablist] [file...]
16

DESCRIPTION

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

OPTIONS

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

OPERANDS

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

STDIN

75       See the INPUT FILES section.
76

INPUT FILES

78       The input files shall be text files.
79

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

109       Default.
110

STDOUT

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

STDERR

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

OUTPUT FILES

119       None.
120

EXTENDED DESCRIPTION

122       None.
123

EXIT STATUS

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

CONSEQUENCES OF ERRORS

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

APPLICATION USAGE

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

EXAMPLES

143       None.
144

RATIONALE

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

FUTURE DIRECTIONS

161       None.
162

SEE ALSO

164       expand, tabs
165
166       The  Base  Definitions  volume  of POSIX.1‐2017, 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-2017, Standard for Information Technology -- Por‐
172       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
173       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
174       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
175       event of any discrepancy between this version and the original IEEE and
176       The Open Group Standard, the original IEEE and The Open Group  Standard
177       is  the  referee document. The original Standard can be obtained online
178       at http://www.opengroup.org/unix/online.html .
179
180       Any typographical or formatting errors that appear  in  this  page  are
181       most likely to have been introduced during the conversion of the source
182       files to man page format. To report such errors,  see  https://www.ker
183       nel.org/doc/man-pages/reporting_bugs.html .
184
185
186
187IEEE/The Open Group                  2017                         UNEXPAND(1P)
Impressum