I have two files:
Ref.txt which contains:
ABCDEFG,15147,ABC,ABCD,ABCDE
HIJKLMN,500,HIJKLM,HIJKL,HIJK
and Seq.txt which contains:
ABCDEFG
ABCXXXX
ABCDXXX
ABCDEXX
HIJKXXX
HIJKLXX
HIJKLMX
HIJKLMN
I would like to search for fields 3-end of each line of the Ref.txt file in the Seq.txt file and replace the lines where that string is found with the string in the first field of that line. The output I am lookin for in this example is this:
ABCDEFG
ABCDEFG
ABCDEFG
ABCDEFG
HIJKLMN
HIJKLMN
HIJKLMN
HIJKLMN
Although this is incorrect code I am thinking of a command like this:
awk '{for(i=3; i<=NF; i++) gsub( $i , $1)}
but where the for loop refers to the the Ref.txt file and the gsub command is executed on the Seq.txt file.