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>s at the beginning of each line into the max‐
20       imum number of <tab>s followed by the minimum number of <space>s needed
21       to  fill  the same column positions originally filled by the translated
22       <blank>s. By default, tabstops shall be  set  at  every  eighth  column
23       position.   Each  <backspace>  shall be copied to the output, and shall
24       cause the column position count for tab calculations to be decremented;
25       the count shall never be decremented to a value less than one.
26

OPTIONS

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

OPERANDS

66       The following operand shall be supported:
67
68       file   A pathname of a text file to be used as input.
69
70

STDIN

72       See the INPUT FILES section.
73

INPUT FILES

75       The input files shall be text files.
76

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

108       Default.
109

STDOUT

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

STDERR

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

OUTPUT FILES

118       None.
119

EXTENDED DESCRIPTION

121       None.
122

EXIT STATUS

124       The following exit values shall be returned:
125
126        0     Successful completion.
127
128       >0     An error occurred.
129
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 spa‐
138       ces  when neither -a nor -t is specified. Users who always want to con‐
139       vert all spaces in a file can easily alias unexpand to use  the  -a  or
140       -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>s into
149       tab stops, where tab stops were a multiple of eight column positions on
150       most  UNIX systems. An early proposal omitted -t because it seemed out‐
151       side the scope of the User Portability Utilities  option;  it  was  not
152       described in any of the base documents.  However, hard-coding tab stops
153       every eight columns was not suitable for  the  international  community
154       and  broke historical precedents for some vendors in the FORTRAN commu‐
155       nity, so -t was restored in conjunction with the list of  valid  exten‐
156       sion  categories  considered by the standard developers. Thus, unexpand
157       is now the logical converse of expand.
158

FUTURE DIRECTIONS

160       None.
161

SEE ALSO

163       expand, tabs
164
166       Portions of this text are reprinted and reproduced in  electronic  form
167       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
168       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
169       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
170       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
171       event of any discrepancy between this version and the original IEEE and
172       The Open Group Standard, the original IEEE and The Open Group  Standard
173       is  the  referee document. The original Standard can be obtained online
174       at http://www.opengroup.org/unix/online.html .
175
176
177
178IEEE/The Open Group                  2003                         UNEXPAND(1P)
Impressum