Reputation: 1049
I am trying to find out which files contains this text 'roads
' on the server, so I use this command: grep -rl 'roads'
. But it shows lots of such files:
./res/js/.svn/entries
./res/js/.svn/all-wcprops
./res/styles/.svn/entries
./res/styles/.svn/all-wcprops
./res/images/.svn/entries
I do not want this folder .svn
show in the search result because this is just for version control, it means nothing for me, so is there a way that I can do this: if the result contains .svn
, then it does not show up in the final result. e.g. below three files contain the text 'roads
':
check.php
./res/js/.svn/entries
./res/js/.svn/all-wcprops
Then the result only shows:
check.php
Upvotes: 0
Views: 103
Reputation: 142615
grep has a feature to exclude a particular directory, called "--exclude-dir", so simply you can pass .svn as "--exclude-dir" param, like below:
"grep -rl --exclude-dir=.svn ./ -e roads"
Upvotes: 1
Reputation: 25855
One simple way is to simply grep away your false positives:
grep -rl roads . | grep -v '/\.svn/'
If you want to be more efficient and not spend time searching through the SVN files, you can filter them away before grepping through them:
find -type f | grep -v '/\.svn/' | xargs grep -l roads
Upvotes: 1