Invert match

Remove comment and blank lines from a config file

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

tool
grep15 commands
tags
grep

More grep commands

  • 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 -l

    List files containing TODO/FIXME/HACK in Python files

  • rg 'panic' -C3 --glob '*.go'

    3 lines of context around matches in Go files

all 15 grep commands