Issue
I'm trying to find lines that start with 'query' or the following sign: '>' but I don't know how to do this.
query=345
query=4565
brink=980
>ehlhdhdk
>blonk
I want to only preserve the lines 1,2,4 and 5.
I have tried: grep -e 'query=' filename.txt||grep -F '>' filename.txt > newfile.txt
and:
cat filename.txt | grep -e 'query='||grep -F '>' > newfile.txt
.
But these do not work and they do not output the newfile.txt and instead they just output into the terminal.
Solution
Use multiple patterns with option -e
:
grep -e '^>' -e '^query' file
Output:
query=345 query=4565 >ehlhdhdk >blonk
Answered By - Cyrus Answer Checked By - Katrina (WPSolving Volunteer)