Luke Oliff.

TIL: Formatting Terminal Output Into Tables With column

·TIL·1 min read·Luke Oliff

Tabular data in the terminal is unreadable until you format it. column -t aligns everything into clean columns.

cat models.tsv | column -t

Input with tab or space separated values becomes a neatly aligned table. column counts the columns from the first row and pads every subsequent row to match.

ps aux | column -t

System command output that wraps or misaligns becomes readable. The terminal width limits the column widths automatically.

cat benchmarks.tsv | column -t -s $'\t' -o ' | '

Set the input separator with -s and the output separator with -o. Pipe delimited tables for markdown style output.

Does column handle headers?

column treats every line the same. The header row is formatted like data. Use head to print the header separately if you need different styling.

Is column available on macOS?

Yes. column is a BSD utility built into macOS.