expand
文字處理
用法
expand -t 4 [file]把定位字元換成空格;Makefile 必須是真正的 tab,對它跑 expand 會讓建置失敗。
常用選項
| 選項 | 含義 |
|---|---|
| -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 |
範例
expand -t 2 old.pyTurns each tab into two spaces.
unexpand -a -t 4 file.txtTurns every four spaces back into a tab.
它們本來就是用管線串起來用的。串三條往往比讓一條命令做完所有事更短。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. expand 是做什麼的?
把定位字元換成空格;Makefile 必須是真正的 tab,對它跑 expand 會讓建置失敗。
Q. 怎麼寫?
expand -t 4 [file] —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 3 個,完整列表在 man expand。這條命令屬於文字處理。
相關命令
man 手冊: man expand