We Recommend

bash Cookbook: Solutions and Examples for bash Users bash Cookbook: Solutions and Examples for bash Users
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages.


Posted By

noah on 01/23/08


Tagged

search filter grep find prune


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

benpjohnson


Exclude some directories from grep


Published in: Bash 


The following command will grep for a string in HTML files, but will skip the directories dirFoo and dirBar. (Thanks Jeff)

  1. find . -name "*.html" \( -name 'dirFoo' -prune -o -name 'dirBar' -prune \) | xargs grep -n "THE_PATH_YOU_ARE_LOOKING_FOR"

Report this snippet 

You need to login to post a comment.