I'm struggling with a basic awk command.
File 1 :
AB253828.1
AB253829.1
AB253830.1
AB253831.1
File 2 :
accession accession.version taxid gi
A00001 A00001.1 10641 58418
A00002 A00002.1 9913 2
A00003 A00003.1 9913 3
A00004 A00004.1 32630 57971
A00005 A00005.1 32630 57972
A00006 A00006.1 32630 57973
A00008 A00008.1 32630 57974
A00009 A00009.1 32630 57975
A00010 A00010.1 32630 57976
both file have >1 000 000 lines
I would like to print columns 2 and 3 of file 2 if column 2 corresponds to the patterns of file 1 I tried a lot of possibilities but none work...
for ACC in $(cat file1.txt)
do
#ACC1=$(echo "\"$ACC\"")
awk -v OFS='\t'-v z="$ACC" '{ if($2 == z) { print $2,$3 } }' file2.txt
done
I got
awk: cannot open { if($2 == z) { print $2,$3 } } file2.txt (No such file or directory)
I checked, file2 is there. I suppose, my problem is the variable z but I can't find the solution.