Linux command
unexpand 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Convert leading spaces to tabs
unexpand [file]
Convert all spaces
unexpand -a [file]
Use a specific tab width
unexpand -t [4] [file]
Convert and save to a new file
unexpand [input.txt] > [output.txt]
Process multiple files
unexpand [file1] [file2]
Read from stdin
cat [file] | unexpand
说明
unexpand converts spaces to tabs in files, writing to standard output. By default, it only converts leading spaces (at the beginning of lines) into the maximum number of tabs followed by the minimum spaces needed to fill the same columns. With -a, all sequences of spaces (not just leading) are converted. Tab stops default to every 8 columns but can be changed with -t. When no file is specified or when file is -, unexpand reads from standard input.
参数
- -a, --all
- Convert all sequences of two or more spaces to tabs, not just leading spaces.
- -t _n_, --tabs=_n_
- Set tab stops every n columns (default: 8).
- -t _list_, --tabs=_list_
- Set tab stops at specified column positions (comma-separated).
- --first-only
- Convert only leading blanks (default behavior).
- --help
- Display help message and exit.
- --version
- Display version information and exit.
FAQ
What is the unexpand command used for?
unexpand converts spaces to tabs in files, writing to standard output. By default, it only converts leading spaces (at the beginning of lines) into the maximum number of tabs followed by the minimum spaces needed to fill the same columns. With -a, all sequences of spaces (not just leading) are converted. Tab stops default to every 8 columns but can be changed with -t. When no file is specified or when file is -, unexpand reads from standard input.
How do I run a basic unexpand example?
Run `unexpand [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a, --all do in unexpand?
Convert all sequences of two or more spaces to tabs, not just leading spaces.