Viewing Linux output in columns


The Linux column command makes it easy to display data in a columnar format — often making it easier to view, digest, or incorporate into a report. While column is a command that’s simple to use, it has some very useful options that are worth considering. In the examples in this post, you will get a feel for how the command works and how you can get it to format data in the most useful ways.

By default, the column command will ignore blanks lines in the input data. When displaying data in multiple columns, it will organize the content by filling the left column first and then moving to the right. For example, a file containing numbers 1 to 12 might be displayed in this order:

1       4       7       10
2       5       8       11
3       6       9       12

A file with some well known lyrics might look like this:

$ cat RR
I've been working on the railroad
All the live long day
I've been working on the railroad
Just to pass the time away

Can't you hear the whistle blowing
Rise up so early in the morn
Can't you hear the whistle blowing
Dinah, blow your horn

Dinah, won't you blow
Dinah, won't you blow
Dinah, won't you blow your horn
Dinah, won't you blow,
Dinah, won't you blow,
Dinah, won't you blow your horn

When we pass the file of lyrics through the column command, we’ll see it in this space-saving format:

Leave a Reply

Your email address will not be published. Required fields are marked *