Skip to content

Instantly share code, notes, and snippets.

@a1phanumeric
Created April 9, 2013 14:35
Show Gist options
  • Star 67 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save a1phanumeric/5346170 to your computer and use it in GitHub Desktop.
Save a1phanumeric/5346170 to your computer and use it in GitHub Desktop.
Grep exclusions. Demonstrates how to exclude multiple directories, and files.
grep -r --color --exclude-dir={custom,lib,scripts} --exclude={*.xml,error_log} "beta" .
@shawnkendrick
Copy link

Awesome, Thanks!

@zhoulaosan0
Copy link

zhoulaosan0 commented Jan 9, 2019

This works both on Mac OS and Linux :)

# --color: highlight matched string
# -r: recursive search
# -i: ignore case
# --exclude: exclude specified files
# --exclude-dir: exclude specified dir

grep --color -r -i "foo\|bar" --exclude={\*.csv,\*.txt} --exclude-dir={.git,.idea,vendor} .

@nadim
Copy link

nadim commented Jan 28, 2019

muchos gracias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment