I typically use column
to convert input into a table, eg:
$ echo 'a\tb\tc\nd\te\tf' | column -t -s $'\t'
a b c
d e f
However it collapses empty columns eg:
$ echo 'a\tb\tc\nd\t\tf' | column -t -s $'\t'
a b c
d f
Rather than printing an empty column when there are consecutive delimiters. This is what I would like, using column
or otherwise:
a b c
d f
Best Answer
If you use
GNU column
:Output:
If
GNU column
is not available, you can use sed to add a space (or something else, e.g. a-
) between the tabs: