Convert tabs to spaces (POSIX)
expand [-t tablist] [file...]
If no number is given, tabs stops are set eight columns apart. If a single number is given, tab stops are set tablist columns apart. If multiple numbers are given, tab stops are set at those columns.
The expand utility copies files or the standard input to the standard output with tab characters replaced by the number of space characters needed to pad to the next tab stop. Any backspace characters encountered in the input are copied to the output and cause the column position count for the tab-stop calculations to be decremented; the count is never decremented below zero.
The -t option lets you specify how many columns tab stops are set apart. You can also use it to specify a multiple tab-stop list that determines where tab stops are placed. If tab characters are present in the input past the last tab stop specified in a multiple tab-stop list, those tabs are each replaced by a single space in the output.
Note that tabbing to position N causes the next character written to appear in the next column position on that line (i.e. column N+1)
For the file myfile, expand each tab to the number of spaces required to reach the next tab stop:
expand myfile
Do the same as above, except set tab stops to every four columns rather than the default eight:
expand -t4 myfile
Place tab stops at the specified columns. Any tab encountered past the last tab stop will be replaced by a single space:
expand -t8,12,20,24,32,36,44,48 myfile
Input files are intended to be composed of ASCII text and white-space. Input is read either from the standard input or from one or more files named on the command line. Multiple input files are processed in the order they appear on the command line.
All output is written to the standard output.
If an error occurs (e.g. failure to open a file named on the command line), a diagnostic message is written to the standard error.
The expand utility does not check to verify that the tabstops specified in the -t option are in ascending order, as is required for proper operation.