Linux:columnコマンドで表形式で出力する方法

スポンサーリンク

columnコマンドで表形式で出力する方法

columnコマンドで表形式で出力するには-tオプションを指定します。

 

オプションの説明

 -t Determine the number of columns the input contains and create a table. Columns are delimited with whitespace, by default, or with the characters supplied using the -s option. Useful for pretty-printing displays.

 

-tオプションを指定した場合(デフォルトはホワイトスペース区切り)

$ cat test.txt
a b c
100 2 3
4 500 6
$ cat test.txt | column -t
a    b    c
100  2    3
4    500  6

-tオプションを指定しない場合

$ cat test.txt
a b c
100 2 3
4 500 6
$ cat test.txt | column
a b c   100 2 3 4 500 6