On a recent project, I was outputting some tab separated data to stdout for debugging. It looked something like this:
Type Result Time (ms)
---- ---- ----
Traditional 54986 0.001842
Range 54986 0.000325
For Each 54986 0.000282
Using the column
command, we can turn this into something much easier to read:
❯ ./measurements | column -t -s $'\t'
Type Result Time (ms)
---- ---- ----
Traditional 56085 0.00169
Range 56085 0.00032
For Each 56085 0.000257
Much better!
The -t
tells column we are working with tabulated data and to assume some defaults. -s $'\t'
specifies that we only want to treat tab as a column separator.
We can also sort these results, but I have to strip the headers from the data to do so:
❯ ./measurements | tail -n +3 | column -tds $'\t' | sort -nk3 -t $'\t'
For Each 48140 0.000277
Range 48140 0.000326
Traditional 48140 0.002078