Skip to content

Instantly share code, notes, and snippets.

@a1phanumeric
Created April 9, 2013 14:35
Show Gist options
  • 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" .
@popovich-ai
Copy link

Thanks!!!

@tsboh
Copy link

tsboh commented Sep 12, 2018

"The --exclude-dir={...} now works on OSX, as far as I can tell." from @jpucinno same for me.
on OSX it works

@paulresdat
Copy link

Gold! thanks buddy!

@shawnkendrick
Copy link

Awesome, Thanks!

@hawkzhou3
Copy link

hawkzhou3 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