# Created on savesnippets.com · https://savesnippets.com/VJjY4qAgWBCGC7 # Count lines matching pattern grep -c "ERROR" /var/log/app.log # Count total matches (not just lines — `-o` prints each match on its own line) grep -o "ERROR" /var/log/app.log | wc -l # Count files that contain at least one match (recursive) grep -rlc "TODO" src/ | wc -l # Top 10 error codes from an access log grep -oE 'HTTP/1\.[01]" [0-9]+' access.log | awk '{print $2}' | sort | uniq -c | sort -rn | head # Count distinct IPs hitting a 500 awk '$9 == 500 {print $1}' access.log | sort -u | wc -l