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

NAME

6       unexpand - convert spaces to tabs
7

SYNOPSIS

9       unexpand [ -a| -t tablist][file...]
10

DESCRIPTION

12       The  unexpand  utility  shall  copy files or standard input to standard
13       output, converting <blank>s at the beginning of each line into the max‐
14       imum number of <tab>s followed by the minimum number of <space>s needed
15       to fill the same column positions originally filled by  the  translated
16       <blank>s.  By  default,  tabstops  shall  be set at every eighth column
17       position.  Each <backspace> shall be copied to the  output,  and  shall
18       cause the column position count for tab calculations to be decremented;
19       the count shall never be decremented to a value less than one.
20

OPTIONS

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

OPERANDS

60       The following operand shall be supported:
61
62       file   A pathname of a text file to be used as input.
63
64

STDIN

66       See the INPUT FILES section.
67

INPUT FILES

69       The input files shall be text files.
70

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

102       Default.
103

STDOUT

105       The standard output shall be equivalent to the  input  files  with  the
106       specified <space>-to- <tab> conversions.
107

STDERR

109       The standard error shall be used only for diagnostic messages.
110

OUTPUT FILES

112       None.
113

EXTENDED DESCRIPTION

115       None.
116

EXIT STATUS

118       The following exit values shall be returned:
119
120        0     Successful completion.
121
122       >0     An error occurred.
123
124

CONSEQUENCES OF ERRORS

126       Default.
127
128       The following sections are informative.
129

APPLICATION USAGE

131       One non-intuitive aspect of unexpand is its restriction to leading spa‐
132       ces when neither -a nor -t is specified. Users who always want to  con‐
133       vert  all  spaces  in a file can easily alias unexpand to use the -a or
134       -t 8 option.
135

EXAMPLES

137       None.
138

RATIONALE

140       On several occasions, consideration was given to adding a -t option  to
141       the  unexpand utility to complement the -t in expand (see expand ). The
142       historical intent of unexpand was to translate multiple  <blank>s  into
143       tab stops, where tab stops were a multiple of eight column positions on
144       most UNIX systems. An early proposal omitted -t because it seemed  out‐
145       side  the  scope  of  the User Portability Utilities option; it was not
146       described in any of the base documents.  However, hard-coding tab stops
147       every  eight  columns  was not suitable for the international community
148       and broke historical precedents for some vendors in the FORTRAN  commu‐
149       nity,  so  -t was restored in conjunction with the list of valid exten‐
150       sion categories considered by the standard developers.  Thus,  unexpand
151       is now the logical converse of expand.
152

FUTURE DIRECTIONS

154       None.
155

SEE ALSO

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