I have file with columns spearated with tab
.
I have file when some rows have empty cells (on begining, in middle).
In such cases column -t -s $'\t'
simply fails:
Input:
$ echo -e 'A\tB\tC\tD\n\tb1\t\td1\n\t\t\td2\na3\t\t\td3' > in.tsv
$ hexdump -C in.tsv
00000000 41 09 42 09 43 09 44 0a 09 62 31 09 09 64 31 0a |A.B.C.D..b1..d1.|
00000010 09 09 09 64 32 0a 61 33 09 09 09 64 33 0a |...d2.a3...d3.|
0000001e
column output:
$ cat in.tsv | column -t -s $'\t'
A B C D
b1 d1
d2
a3 d3
instead of:
A B C D
b1 d1
d2
a3 d3
Could you recommend how to do TSV command line formatting ? (in Unix way, I want to pipe output of program into formatter, like column
)
Any way of "fixing" column
approach? Maybe another tool?
\1
with empty string? – Grzegorz Wierzowiecki Jan 13 '12 at 14:22\(^\)
alone matches an empty string, anchored to the beginning of line.\1
"produces a copy" of that empty string. – angus Jan 13 '12 at 16:22