One of my favorite BASH commands is:
find . -name '*.*' -exec grep 'SearchString' {} /dev/null \;
which searches the contents of all of the files at and below the current directory for the specified SearchString. As a developer, this has come in handy at times.
Due to my current project, and the structure of my codebase, however, I'd like to make this BASH command even more advanced by not searching any files that are in or below a directory that contains ".svn", or any files that end with ".html"
The MAN page for find kind of confused me though. I tried using -prune, and it gave me strange behavior. In an attempt to skip only the .html pages (to start), I tried :
find . -wholename './*.html' -prune -exec grep 'SearchString' {} /dev/null \;
and did not get the behavior I was hoping for. I think I might be missing the point of -prune. Could you guys help me out?
Thanks
find
is not a build-in bash command but a separate programgrep -rl 'SearchString'
find
to search inside a file.-name '*.*'
does not find all files: only those with a.
in their name (the use of*.*
is typically an DOS-ism, whereas in Unix, you normally use just*
for that). To really match them all, just remove the argument altogether:find . -exec ...
. Or if you want to only apply grep to files (and skip directories) then dofind . -type f -exec ...
.