This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Keep duplicate searches with grep

Hi there,

I want to find word 1 and word 2 in the file concatenate.txt and find the lines that match. However, if I search for word1 three times, I would like the result to come out 3 times too. I have been trying different grep options but it doesn't work. I have also tried with a loop awk. Would you know how to do it?

$ grep 'word1\|word1\|word1\|word2' concatenate.txt

It returns:

>word1 CCUG 34288 CCUG34288T_0000003
>word2 T14V chromosome, complete genome

My ideal result would be:

>word1 CCUG 34288 CCUG34288T_0000003
>word1 CCUG 34288 CCUG34288T_0000003
>word1 CCUG 34288 CCUG34288T_0000003
>word2 T14V chromosome, complete genome
regex grep

0 answers

No answers yet.

Log in to answer this question.