I have two files, one with a newline separated list of number IDs
>cat list.txt
3342
232
...
and one with those IDs and some sequence data in the line after
>cat Seqeunce.txt
>600
ATCGCGG
>3342
ACTCGGTC
>232
TGTGCT
>3342
ACGCGGTC
I would like to print all lines with the ID match and the next line, but only the first time a match is found. So, the out put would be:
> ...some code... list.txt Sequence.txt
>3342
ACTCGGTC
>232
TGTGCT
Note that only the line with the first occurrence of ID 3342, and the next line, is printed
I tried using grep,
grep -f list.txt -A 1 -m 1 Sequence.txt
But it wasnt working. Just running grep -A 1 and -m 1 with the actual ID produced what I want, but I have thousands of IDs and cant run each by hand.