In the awk
below I am trying to use the file1
as a match to file2
. In file2
the contents of $5,&6,and $7
(always tab-delimited) and are copied to the output
under the header Quality metrics. The below executes but the output is empty. I have added comments to help and show my thinking. Thank you :).
$5 = Total_Targets with value under it that can be a decimal or integer
$6 = Targets_less_than250x with value under it that can be a decimal or integer
$7 = Percent_more_than250x with value under it that can be a decimal or integer
file1 (123_Last-First_250x.txt)
Position Gene Type Reads Total_Targets Targets_less_than250x Percent_more_than250x
chr4:55141051 PDGFRA NOCALL 13 2353 1 99.9575
file2 (123_Last-First_oca.txt)
Controls:
4 expression controls detected
desired output (123_Last-First_oncomine.txt)
Quality metrics:
Total_Targets Targets_less_than250x Percent_more_than250x
2353 1 99.9575
Controls:
4 expression controls detected
awk
portion in bold grabs $5,$6,$7
in file1
and stores it in array A and prints it in file2
'
portion in teal adds the header to the output
awk 'FNR==NR{A[$5,$6,$7]=$0;next}$1 in A' OFS=\'t' 123_Last-First_250x.txt 123_Last-First_oca.txt | awk 'NR>1{print "Quality metrics:"}' > output