6 ms·
`column` is nice, but fails on empty cells and cells with escapes or quotes
by ipdashc 5y ago
`column` is nice, but fails on empty cells and cells with escapes or quotes
- globular-toast 5y agoYeah, `column | less -S` works fairly well but empty cells and escaping etc. turns up too often. It essentially means you need a proper CSV parser, which is non-trivial. The other common problem was long values making the output unreadable. Some kind of default truncation is essential.
- darrenf 5y agoI agree `column` is imperfect, but empty cells at least don't seem to be a problem. $ 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.