I want to search for the occurrence of string1 OR string2 OR string3, etc. in a file, and print only those lines (to stdout or a file, either one). How can I easily do this in bash?
you can also use awk
awk '/string1|string2|string3/' file
With awk, you can also easily use AND logic if needed.
awk '/string1/ && /string2/ && /string3/' file
grep "string1\|string2\|string3" file_to_search_in
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With