Convert tabs to spaces.
The expand command converts tab characters in files to the appropriate number of spaces, based on tab stop positions. By default, tab stops are set at every 8th column.
The -t option allows setting custom tab stop positions, either as a single number for uniform spacing or as a comma-separated list of specific positions.
expand is useful for preparing files for display in environments that do not handle tabs well, normalizing indentation, and ensuring consistent formatting across different editors and terminals.
| Name | Description | Optional |
|---|---|---|
file |
One or more files to process. Reads from stdin if omitted. | Yes |
-t |
Set tab stops at the specified positions instead of every 8 columns. | Yes |
expand file.txt
expand -t 4 source.c
expand -t 2,4,8 data.txt