Print only matched part grep
Extract IP addresses from log using Perl regex
grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' access.log | sort -u
more grep
all 15 commands →
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/
ripgrep fast search
rg 'TODO|FIXME|HACK' --type py -l