column

テキスト処理

書き方

column -t [file]

欄を詰めて桁を揃え、表のように見せます。連続した区切りを一つと数えるので、空のセルがある CSV は一つずつずれます。

よく使うオプション

オプション意味
-tWork out the columns and line them up as a table
-sWhich characters separate the input columns, with -t
-xFill columns before rows
-cFormat for a display this many characters wide
-outil-linux: what to put between the output columns

mount | column -t

Lines the mount table up.

column -t -s, data.csv

Reads a CSV into aligned columns.

ls | column -x

Prints the listing in columns across the screen.

パイプでつないで使うのが本来の形です。ひとつで全部やるより、三つつないだ方が短くなります。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. column は何をしますか。

欄を詰めて桁を揃え、表のように見せます。連続した区切りを一つと数えるので、空のセルがある CSV は一つずつずれます。

Q. どう打ちますか。

column -t [file] — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは5個です。全部は man column にあります。このコマンドはテキスト処理の仲間です。

関連するコマンド

man ページ: man column