Search recursively, ignoring case

Find "error" in any case in all files under /var/log

grep -ri 'error' /var/log/

tool
grep15 commands
tags
grep

More grep commands

  • grep -B3 -A5 'FATAL' app.log

    Print 3 lines before and 5 lines after each match

  • grep -c 'POST /api' /var/log/nginx/access.log

    Print only the number of matching lines

  • grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' access.log | sort -u

    Extract unique IP addresses from a log with a Perl regex

  • grep -v '^#' /etc/nginx/nginx.conf | grep -v '^\s*$'

    Show a config file without comments and blank lines

  • grep -r --include='*.py' 'import os' /srv/app/

    Limit a recursive search to .py files

all 15 grep commands