@HW-ST997:122 AGAT + #11B @HW-ST997:120 GATC + #BCI @HW-ST997:112 AGCT + # :BDI --------------------- Explanation: every four lines represent a sequence, the first line is the head (ID) of that sequence.

I have file2 as below: @HW-ST997:120 @HW-ST997:112 @HW-ST997:110 @HW-ST997:108 ------------------------ Explanation: In file2, there are IDs of the sequences.

What I want to do is to keep only the sequences in file1 whose IDs can be found in file2. Notice, I want to keep the whole thing, I mean, not only the IDs, but also the 2nd, 3rd, 4th lines for each sequence information.