OpenBSD manual page server

Manual Page Search Parameters

EXPAND(1) General Commands Manual EXPAND(1)

expand, unexpandexpand tabs to spaces, and vice versa

expand [-t tablist] [file ...]

unexpand [-a] [file ...]

expand processes the named files or the standard input, writing the standard output with tabs changed into blanks. Backspace characters are preserved into the output and decrement the column count for tab calculations. expand is useful for pre-processing character files (before sorting, 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:

By default, only leading blanks and tabs are reconverted to maximal strings of tabs. If the -a option is given, tabs are inserted whenever they would compress the resultant file by replacing two or more characters.
tablist
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, separated by commas or single blank characters, 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 replaced 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 (-).

The expand and unexpand utilities exit 0 on success, and >0 if an error occurs.

fold(1)

The expand and unexpand utilities are compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification, except that this implementation does not support a -t flag for unexpand.

The ability to specify tabstops without the -t flag is not specified by IEEE Std 1003.1-2008 (“POSIX.1”), though it states it “may be present in some implementations”.

The expand utility first appeared in 1BSD.

March 17, 2014 OpenBSD-6.4