To search for multiple patterns in a file using the grep command, you can use the -E option for extended regular expressions or the -e option to specify multiple patterns. Here are a couple of examples:
Using -E for Extended Regular Expressions
You can use the pipe | to separate multiple patterns:
grep -E "pattern1|pattern2|pattern3" filename.txt
Using -e Option
You can specify each pattern with the -e option:
grep -e "pattern1" -e "pattern2" -e "pattern3" filename.txt
Example
If you want to search for lines containing either "ERROR" or "WARNING" in a log file, you can use:
grep -E "ERROR|WARNING" server_log.txt
or
grep -e "ERROR" -e "WARNING" server_log.txt
Both commands will return lines from server_log.txt that contain either "ERROR" or "WARNING".
