How do I match more than one regular expression using grep?
-
The pipe character
|
means OR in regular expressions.Example text file used.
$ cat textfile If the boots fit bootsy was here 123456789
We want to match any upppercase letter or anything with boots in the line. From out text file both regular expressions match, and hence only the numbers are excluded.
$ grep -E "[A-Z]|boots" textfile If the boots fit bootsy was here
© Lightnetics 2024