Hi everyone,
I have two .tsv files. I want to match 3rd column of both files and if the value in each field matches, I want to print the entire row but also add columns 13th, 14th, 15th and 16th of file2.tsv in file1.tsv (append after 10th column of file1.tsv). Also if the value in 3rd column of both files doesn't match, the code should add "-" to the new file where fields from 13th, 14th, 15th and 16th of file2.tsv will be added.
I am trying awk command, but in case of a mismatch, "-" is added to only one column (11th) and rest of the three columns are from the original file1.tsv. Please help
awk -v OFS="\t" 'NR==FNR {a[$3]=$13"\t"$14"\t"$15"\t"$16;next}{$10=$10 "\t" (a[$3]?a[$3]: "-")}1' file1.tsv file2.tsv >
output.tsv
Hello ehsanullah83,
code
option) to present your post better. I've done it for you this time.Thanks!
fin swimmer
Good description of data and required output . Could you post example data and expected output? @ ehsanullah83