Search notes:

Shell command: column

column creates visually appealing tables. By default, every line is interpreted as a cell for the table.
The -c option determines the width of the created table (c stands for console columns, not for table columns).
Here's an example with the following simple file:
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fivteen
sixteen
seventeen
eighteen
nineteen
twenty
Github repository shell-commands, path: /column/testfiles/numbers.txt
The following command
column -c 40 testfiles/numbers.txt
Github repository shell-commands, path: /column/c_display-width_40
turns the file into
one          eleven
two          twelve
three        thirteen
four         fourteen
five         fivteen
six          sixteen
seven        seventeen
eight        eighteen
nine         nineteen
ten          twenty
With -c 60, I can specify the output to be wider:
column -c 40 testfiles/numbers.txt
Github repository shell-commands, path: /column/c_display-width_40
one          eight           fivteen
two          nine            sixteen
three        ten             seventeen
four         eleven          eighteen
five         twelve          nineteen
six          thirteen        twenty
seven        fourteen
Unfortunately, the output is separated by tabs, not by whitespaces!

Table mode

In table mode, column determines the number of columns the input contains and creates a table. non-interactive mode (see --output-width for more details).
Table mode is enabled with -t (or --table).
Column formatting can be adjusted with --table-* options.
Table mode is likely the mode that should be used in most cases.

Seperate input by tabulators

In order to specify that the input is separated by tabulators, -s'\t' can be used:
$ echo -e "first\tsecond\tthird
AAA\tBBB\tCCC
abc def\tgh ijkl mnopq\trs tuv wxyz
" | column -t -s $'\t'
first    second         third
AAA      BBB            CCC
abc def  gh ijkl mnopq  rs tuv wxyz

See also

cut to cut specific columns.
commands
Tabular data
Vim: aligning text on commas

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Linux/sh...', 1788337131, '216.73.217.21', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Linux/shell/commands/column(131): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78