expand(C)
expand --
convert tabs to spaces
Syntax
expand [ -t tablist ]
[ file ... ]
expand [ -tabstop ]
[ -tab1, tab2, ..., tabn ]
[ file ]
unexpand [-a | -t tablist ]
[ file ... ]
Description
expand reads either its standard input or the named files,
replaces all tabs with spaces, and writes its output to the standard
output. When a backspace character is encountered the column count
is decremented (for tab stop calculations) and the backspace
character is copied to the standard output unchanged.
The second form of expand uses a single number to specify
the tab interval, tabstop, preceded by a minus
sign. Multiple tab stops are specified after a leading minus sign as
tab1, tab2 and so on.
unexpand reads the standard input or the named files, and
replaces leading blanks with the maximum number of tabs followed by
the minimum number of spaces necessary to provide an equivalent
indentation. The output is then written to the standard output. If a
backspace character is encountered in the input, unexpand
decrements its column counter then copies the backspace character to
the output.
By default, tab stops are set at every eighth column position.
The following options are recognized:
-a-
By default, unexpand translates any leading blanks that
it encounters. If the -a option is given, all sequences
of two or more spaces preceding a tab stop are translated into
the maximum corresponding number of tabs followed by the minimum
number of spaces necessary to match the indentation.
-t tablist-
tablist is a single argument consisting of positive
integers separated by spaces or commas. If only a single number
is given, tabs are set at column positions tablist
columns apart, instead of the default. If multiple numbers are
specified, tab stops are set at those column positions. No space
to tab conversions are made by unexpand for positions
past the last specified tab stop, and expand replaces
any tabs past the last given tab stop with spaces (one space per
tab).
When the -t option is used for unexpand,
-a is assumed.
Exit values
expand and unexpand return the following values:
0-
successful completion
>0-
an error occurred
Examples
Convert tabs to spaces in tabbed.file, and send output to
un.tabbed.file, where tabs are located at column positions
in multiples of 5 spaces:
expand -t 5 <tabbed.file >un.tabbed.file
Convert spaces to tabs in txtfile, and send output to
tabbed.file:
unexpand <txtfile >tabbed.file
See also
tabs(C)
Standards conformance
expand and unexpand are conformant with:
ISO/IEC DIS 99452:1992, Information technology Portable Operating System Interface (POSIX) Part 2: Shell and Utilities (IEEE Std 1003.21992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003