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