Extended regex alternation grep
Match lines containing ERROR, WARN, or CRIT
grep -E '(ERROR|WARN|CRIT)' app.log | tail -50
more grep
all 15 commands →
Recursive case-insensitive search
grep -ri 'error' /var/log/
Show context lines
grep -B3 -A5 'FATAL' app.log
Count matches
grep -c 'POST /api' /var/log/nginx/access.log
Print only matched part
grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' access.log | sort -u
Invert match
grep -v '^#' /etc/nginx/nginx.conf | grep -v '^\s*$'