Count matches grep
Print only the number of matching lines
grep -c 'POST /api' /var/log/nginx/access.log
more grep
all 15 commands →
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*$'
Search only in file type
grep -r --include='*.py' 'import os' /srv/app/
Exclude directories
grep -r --exclude-dir='.git' --exclude-dir='node_modules' 'TODO' .
Print filename and line number
grep -rn 'panic:' /var/log/app/