I have a file1.txt and file2.txt i would like to print the matching lines to a new files
file1.txt
FOMPING00002015
FOMPING00008750
FOMPING00003379
FOMPING00009073
FOMPING00007164
FOMPING00009598
file2.txt
>FOMPING00013293 Protein of unknown function
ATGCCCTGCTCGTCGCTCGAGCGGGATCATAGCCAGCATGAAGTTATACCGTCATCGCAG
AGCCAGGAACGCGACTTTGTGCCGCCTAATGGTGACATCAGGAGTCGGGCGAGAACGACA
TCCGACGAAATTGTACCCACATCGCAG
>FOMPING00003379 Protein of unknown function
ATGCCCTGCTCGTCGCTCGAGCGGGATCATAGCCAGCATGAAGTTATACCGTCATCGCAG
AGCCAGGAACGCGACTTTGTGCCGCCTAATGGTGACATCAGGAGTCGGGCGAGAACGACA
TCCGACGAAATTGTACCCACATCGCAGTA
>FOMPING00009073 Protein of unknown function
ATGTCCTCTTGGTCTGGTTCTTCTTACCCTCCACCTCCACGCGCACGTTCGCGCTCTCGC
TCCCCTTATCGTGGGTCTTATCCTGCGAGACCCGGGTATCCAGAGCCTGGATACTCGCAG
>FOMPING00000581 Similar to mcs4: Response regulator mcs4
ATGTCCTCTTGGTCTGGTTCTTCTTACCCTCCACCTCCACGCGCACGTTCGCGCTCTCGC
TCCCCTTATCGTGGGTCTTATCCTGCGAGACCCGGGTATCCAGAGCCTGGATACTCGCAG
GATCCATACCGTGCCGACTGGGAGGCTTATGACAGAGAGCGCGCATGGGCCTCCTACGAG
I have tried few commands
grep -F file1.txt file2.txt > output.txt
grep -Ff file1.txt file2.txt > output.txt
both the commands outputs just the first line from file2.txt
output.txt
>FOMPING00013293 Protein of unknown function
>FOMPING00000581 Similar to mcs4: Response regulator mcs4.
I want the output file just like the file2.txt with sequences in it.
Thank you
-A X
. Is the number of lines after each match constant? If not, you'll have to parsefile2.txt
and match "headers" with their "sequence" lines. But if it's always just one line, you can do-A 1
.>
?awk
is what you need. But if I were doing this and similar things with arbitrary, "inconveniently" structured input data (briefly looking at your question history), I would skipawk
and shoot straight to my favorite programming language.awk
is a very powerful tool but also antiquated. In the modern age you'll (probably) enjoy modeling your data in something like golang/ruby/python/etc compared to awk. I cannot tell you how to do this inawk
.