Given perhaps comma- or tab-delimited input, I'd like to present a series of appropriately padded columns to stdout, so I can easily scan columnar information which would otherwise present rather messily.
I've tried troff
-based solutions and while the simple demos have worked, feeding the command actual input has resulted in bizarre errors. I've currently resorted to using a sed
-based method hack which is rather slow…
EDIT: column
is quite a useful tool, however it'd be really awesome if I the columns had, say, a pipe character (|
) between them so they do not appear to "float" in space and I can easily distinguish where each starts.
PS. This post's title used to read 'ASCII "table"', not 'ASCII-art table'. Edited to try and remove confusion.
Best Answer
Assuming a CSV file, you can use
column(1)
like so:This is included in the
bsdmainutils
package on my Debian distribution, so I'm not sure how portable it is.Two more things to note:
a,b,"c,d"
as four columns not three.