Linux command
expand 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Convert tabs to
expand [file.txt]
Set tab width
expand -t [4] [file.txt]
Custom tab stops
expand -t [4,8,12] [file.txt]
Process multiple files
expand [file1.txt] [file2.txt]
Only convert leading tabs
expand -i [file.txt]
Read from stdin
cat [file.txt] | expand
说明
expand converts tab characters to spaces. It's commonly used to normalize text files for consistent display or before processing by tools that don't handle tabs well. By default, tabs expand to 8-space intervals. Custom tab widths or specific tab stop positions can be set. The --initial option only converts tabs at line beginnings. expand is the inverse of unexpand, which converts spaces to tabs.
参数
- -t _N_
- Tab width (default: 8).
- -t _LIST_
- Comma-separated tab stop positions. Last value can be prefixed with `/` for repeating interval or `+` for relative alignment.
- -i, --initial
- Only convert tabs before non-blank characters on each line.
- --help
- Display help information.
- --version
- Output version information and exit.
FAQ
What is the expand command used for?
expand converts tab characters to spaces. It's commonly used to normalize text files for consistent display or before processing by tools that don't handle tabs well. By default, tabs expand to 8-space intervals. Custom tab widths or specific tab stop positions can be set. The --initial option only converts tabs at line beginnings. expand is the inverse of unexpand, which converts spaces to tabs.
How do I run a basic expand example?
Run `expand [file.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -t _N_ do in expand?
Tab width (default: 8).