Print only matched part
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 commands
-
grep -v '^#' /etc/nginx/nginx.conf | grep -v '^\s*$'Remove comment and blank lines from a config file
-
grep -r --include='*.py' 'import os' /srv/app/Limit recursive search to .py files only
-
grep -r --exclude-dir='.git' --exclude-dir='node_modules' 'TODO' .Search recursively skipping vcs and dependency dirs
-
grep -rn 'panic:' /var/log/app/Show file and line number for each match
-
rg 'TODO|FIXME|HACK' --type py -lList files containing TODO/FIXME/HACK in Python files