This post explains when using the command line utility 'find', how to
use the '-prune' option, to exclude particular files or directories
from finds search results.
This is a response to a question on a forum asked a long time ago. As
I sometimes forget myself, how to properly use the '-prune' option of
'find', I thought I'd leave this note here.
For the sake of completeness, the '-prune' option works like this.
find (where to look) (what to prune) -o (what to find) -print
where to look = path to search, i.e. "." or "/home/john"
what to prune = statement regarding what we will remove, to remove a
directory, you use "-path './path_to_remove' -prune". This tells find
that any path matching ./path_to_remove will be pruned. The confusing
thing here, is we are using multiple command line options together as
one directive.
what to find = search term, i.e. "-iname 'file_to_find'".