Grep for multiple strings in one command

Grep can be used to look for more than one pattern in only one run.

The basic usage of grep is for looking for one string in a file, or multiple files, like:

grep '<id>' my_file.xml

but we can also do an OR in the search string:

grep '<id>\|<title>' my_file.xml

Then you will get the lines containing both <id> and <title>.

All posts by Julià

Our most read posts

10 questions for Tom Hare

Today, Dev-Strategist Tom Hare is going to answer 10 questions about his work and life at the netzstrategen. 1. When did you become part of the team? I joined the netzstrategen team in May 2017, shortly after moving to Karlsruhe …

10 questions for Luca Pipolo

Today Dev-Strategist Luca Pipolo is going to answer 10 Questions about his work and life at the netzstrategen company. 1. Since when have you been part of the team? More or less since March of this year, when I left …