The files are tab separated.
I have "N" number of files whose contents are as shown in the screenshot above. I want to merge them and append the 5th column. The first 4 columns are the same.
I tried with the awk
command below for files 1 and 2:
awk 'NR==FNR{a[NR]=$0;next} {print a[FNR] "\t",$5}' file1 file2
it only appends for 2 files, not more than 2.
How can I do this correctly using awk
, paste
or other tools?
Best Answer
If the first four columns are identical across files you could run something like
This will
paste
all files then extract fields 1-5 and every 5th field after.