column
文字處理
用法
column -t [file]給欄位補空白讓各欄對齊成表格;連續的分隔符號只算一個,所以有空儲存格的 CSV 會整行錯位。
常用選項
| 選項 | 含義 |
|---|---|
| -t | Work out the columns and line them up as a table |
| -s | Which characters separate the input columns, with -t |
| -x | Fill columns before rows |
| -c | Format for a display this many characters wide |
| -o | util-linux: what to put between the output columns |
範例
mount | column -tLines the mount table up.
column -t -s, data.csvReads a CSV into aligned columns.
ls | column -xPrints the listing in columns across the screen.
它們本來就是用管線串起來用的。串三條往往比讓一條命令做完所有事更短。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. column 是做什麼的?
給欄位補空白讓各欄對齊成表格;連續的分隔符號只算一個,所以有空儲存格的 CSV 會整行錯位。
Q. 怎麼寫?
column -t [file] —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 5 個,完整列表在 man column。這條命令屬於文字處理。
相關命令
man 手冊: man column