by darrenf · 4y ago · 0 comments
Not 100% sure I understand your requirement, but does `column` fit the bill?
$ echo -e "foo,bar,quux\n1,2,3" | column -t -s,
foo bar quux
1 2 3 $ echo -e 'foo,bar,quux\n1,,3' | column -t -s,
foo bar quux
1 3
The man page says:> Version 2.23 changed the -s option to be non-greedy
Elsewhere on an ancient Ubuntu I have lying around, `-n` did the same:
-n By default, the column command will merge multiple adjacent delimiters into a single delimiter when using the -t option; this option disables that behavior. This option is a Debian GNU/Linux extension.