expand
Text processing
Usage
expand -t 4 [file]Turns tab characters into spaces; a Makefile needs real tabs to work, so running expand on one breaks the build.
Common flags
| Flag | Meaning |
|---|---|
| -t | Tab width, or a comma-separated list of tab stops |
| -i | GNU: convert only the tabs at the start of a line |
| unexpand -a | The reverse: turn runs of spaces back into tabs |
Examples
expand -t 2 old.pyTurns each tab into two spaces.
unexpand -a -t 4 file.txtTurns every four spaces back into a tab.
These were built to be piped together. Three joined commands are usually shorter than one that does everything.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does expand do?
Turns tab characters into spaces; a Makefile needs real tabs to work, so running expand on one breaks the build.
Q. How do I type it?
expand -t 4 [file] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
3 are listed here; the full set is in man expand. This command sits under Text processing.
Related commands
man page: man expand