list.txt
GETID_17049_knownids_1/2_Confidence_0.625_Length_2532
GETID_9248_knownids_6/10_Confidence_0.439_Length_2474
GETID_11084_knownids_3/3_Confidence_0.600_Length_1451
GETID_15916_knownids_10/11_Confidence_0.324_Length_1825
sample1.txt
>GETID_17049_knownids_1/2_Confidence_0.625_Length_2532
sampletextforsample1
sampletextforsample1
sampletextforsample1
>GETID_18457_knownids_1/2_Confidence_0.625_Length_2532
sample2textforsample1
sample2textforsample1
sample2textforsample1
sample2textforsample1
sample2.txt
>GETID_11084_knownids_3/3_Confidence_0.600_Length_1451
sampletextforsample2
sampletextforsample2
>GETID_67838_knownids_3/3_Confidence_0.600_Length_1451
sample2textforsample2
sample2textforsample2
sample3.txt
>GETID_17049_knownids_1/2_Confidence_0.625_Length_2532
sampletextforsample3
sampletextforsample3
sampletextforsample3
>GETID_15916_knownids_10/11_Confidence_0.324_Length_1825
sample2textforsample3
sample2textforsample3
output.txt
>GETID_17049_knownids_1/2_Confidence_0.625_Length_2532
sampletextforsample1
sampletextforsample1
sampletextforsample1
>GETID_17049_knownids_1/2_Confidence_0.625_Length_2532
sampletextforsample3
sampletextforsample3
sampletextforsample3
>GETID_11084_knownids_3/3_Confidence_0.600_Length_1451
sampletextforsample2
sampletextforsample2
>GETID_15916_knownids_10/11_Confidence_0.324_Length_1825
sample2textforsample3
sample2textforsample3
I want to read each line from list.txt (by capturing bracketed values (GETID_{17049}knownids{1/2}_Confidence_1.0_Length_{2532}) and compare with sample1.txt, sample2.txt, sample3.txt has multiple line and print the contents (output.txt) from these files when it is matched with list.txt. The output should contain exact match to list.txt. Any help in awk/sed/perl is appreciated.
grep -F -A 1 -f list.txt sample[123].txt | grep -vx '--'get to what you want?