Text Processing
unexpand
Convert spaces in input to tabs.
Synopsis
syntax
unexpand [OPTION]... [FILE]...
Examples
Convert spaces to tabs
unexpand -a file.txt
Convert 4-space sequences to tabs
unexpand -t 4 file.txt
Convert only leading spaces
unexpand --first-only file.txt
Common options
| Flag | Description |
|---|---|
| -a | Convert all suitable sequences of spaces, not just leading |
| -t | Set tab stops |
| --first-only | Convert only leading sequences of spaces |
About unexpand
The `unexpand` command convert spaces in input to tabs. Text processing commands transform, format, and generate text output.
Linux's philosophy of small composable tools shines here — these commands are designed to be piped together to build complex text-processing workflows. They are indispensable for scripting, log analysis, and data transformation tasks.
The command accepts 3 commonly used flags shown above, though the full set of options is available in the man page (`man unexpand`). The 3 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Text Processing Commands
Other commands in the Text Processing category