On Unix-like operating systems, the expand command copies files (or the standard input) to the standard output, with tab characters expanded to space characters. Backspace characters are preserved into the output and decrement the column count for tab calculations.
The unexpand command reverses this process.
This page covers the GNU/Linux versions of expand and unexpand.
Description
expand is useful for pre-processing character files (before sorting, looking at specific columns, and so forth) that contain tab characters.
- Description
- Syntax
- Examples
- Related commands
- Linux commands help
Syntax
expand [OPTION]… [FILE]…
unexpand [OPTION]… [FILE]…
Expand options
Unexpand options
Examples
expand myfile.txt
Expand the file myfile.txt, changing tabs to spaces, and display on standard output.
expand –tabs=10 myfile.txt > myfile2.txt
Converts the tabs in the file myfile.txt to 10 spaces each, and write the output to myfile2.txt.
Related commands
tabs — Set tab stops on a terminal.