Match several words with -E
Show the last 50 lines that contain ERROR, WARN or CRIT
grep -E '(ERROR|WARN|CRIT)' app.log | tail -50
More grep commands
-
grep -ri 'error' /var/log/Find "error" in any case in all files under /var/log
-
grep -B3 -A5 'FATAL' app.logPrint 3 lines before and 5 lines after each match
-
grep -c 'POST /api' /var/log/nginx/access.logPrint only the number of matching lines
-
grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' access.log | sort -uExtract unique IP addresses from a log with a Perl regex
-
grep -v '^#' /etc/nginx/nginx.conf | grep -v '^\s*$'Show a config file without comments and blank lines