Tabular display in Linux terminal

A command I like in Linux is ‘column’. It allows the display of ordered data (typically CSV) in a tabular way in the Linux terminal.

For example, assume you have the following file:

$ cat data
server|location|usage
mars.example.com|New York|web
saturn.example.com|Beijing|database
mercury.example.com|Sidney|nosql

You can display this file nicely as follows:

$ column -t -s '|' data
server               location  usage
mars.example.com     New York  web
saturn.example.com   Beijing   database
mercury.example.com  Sidney    nosql

-t indicates that we want tabular display and -s specifies the separator we use. I like to use the pipe (‘|’) as data separator, but usually the semi colon (‘;’) is used for CSV data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s