EXPAND(1)                  OpenBSD Reference Manual                  EXPAND(1)

NAME
     expand, unexpand - expand tabs to spaces, and vice versa

SYNOPSIS
     expand [-t tablist] [file ...]
     unexpand [-a] [file ...]

DESCRIPTION
     expand processes the named files or the standard input, writing the stan-
     dard output with tabs changed into blanks.  Backspace characters are pre-
     served into the output and decrement the column count for tab calcula-
     tions.  expand is useful for pre-processing character files (before sort-
     ing, looking at specific columns, etc.) that contain tabs.

     unexpand puts tabs back into the data from the standard input or the
     named files and writes the result on the standard output.

     The options are as follows:

     -a    (unexpand only) By default, only leading blanks and tabs are recon-
           verted to maximal strings of tabs.  If the -a option is given, tabs
           are inserted whenever they would compress the resultant file by re-
           placing two or more characters.

     -t tablist
           (expand only) If the argument to -t, tablist, consists of a single
           numerical argument, tabs are set tablist spaces apart instead of
           the default 8.  If multiple -t options are given, then the tabs are
           set at those specific columns.

           Otherwise the argument to -t may consist of a list of two or more
           positive decimal integers, comma separated, in ascending order: in
           the event of having to process a <tab> at a position beyond the
           last of those specified in a multiple -t list, the <tab> is re-
           placed by a single <space> character.

           This implementation of expand additionally allows tablist to be
           specified without using the -t flag, by prefixing tablist with a
           dash (-).

SEE ALSO
     fold(1)

STANDARDS
     The expand and unexpand utilities are compliant with the IEEE Std
     1003.1-2008 (``POSIX'') specification, with the following exceptions:

           o   POSIX does not support specifying tabstops without use of the
               -t flag.

           o   POSIX specifies that multiple tabstops may be given separated
               by commas or blanks.  This implementation supports only comma-
               separated tabstops.

           o   unexpand does not recognise the -t flag.

HISTORY
     The expand command appeared in 3.0BSD.

OpenBSD 4.7                    February 8, 2009                              1
