I have four TSV files like this:
file_1:
abc \t 1
def \t 3
ghi \t 5
file_2:
abc \t 10
def \t 4
ghi \t 7
file_3:
abc \t 8
def \t 5
ghi \t 1
file_4:
abc \t 4
def \t 2
ghi \t 1
I want to combine those TSV files into the one TSV like this:
dataset \t file_1 \t file_2 \t file_3 \t file_4
abc \t 1 \t 10 \t 8 \t 4
def \t 3 \t 4 \t 5 \t 2
ghi \t 5 \t 7 \t 1 \t 1
How I can get that?
Using awk:
If you need sorted output, either pipe the result through
sort
or (assuming GNU awk 4.0 or above) addPROCINFO["sorted_in"] = "@ind_str_asc"
in either theBEGIN
orEND
block.Using Miller
With a sufficiently new version of Miller you can use the shorthand
nest --ivar tab -f 2
in place ofnest --implode --values --across-records -f 2 --nested-fs tab
Using Miller (https://github.com/johnkerl/miller) and running
you will have