Template A.tsv
:
Name data
B
C
And several files to analyse, for example, B.txt
:
#bla
#blabla
16 LSD
and C.txt
:
#bla
#blabla
16 ARH
I want to add OK or KO to A.tsv
based on whether LSD
is present in the other files:
Name data
B OK
C KO
The field separators are tabs (\t
) for all files. How to do that with awk?
I started with FILENAME recognition but no clue for the rest:
template="A.tsv"
for bla in data/*.txt ; do
r="$(basename -s ".txt" $bla)"
( head -n 1 $template
awk -F'\t' -v OFS="\t" -v filename=$r [..........] >> output_final.tsv;
done