

prune only works with -print and no other actions. To avoid printing the directory altogether, use a syntax that logically omits it. TRUE That's intended behavior, it just doesn't descend into it.prune does what it's intended to, but are still some things you have to take care of when using it. Just specifying -not -path will still descend into the skipped directory, but -not -path will be false whenever find tests each file. prune stops find from descending into a directory. GNU Opinion To ignore a directory and the files under it, use -prune There is clearly some confusion here as to what the preferred syntax for skipping a directory should be. If on the other hand you run find like this cd /tmp find. Note : If you want to exclude /tmp/foo/bar and you run find like this " find /tmp \(." then you must specify -path /tmp/foo/bar. This comes from an actual use case, where I needed to call yui-compressor on some files generated by wintersmith, but leave out other files that need to be sent as-is.

The way -prune works is that anything that, once it is reached, the files below that directory are permanently ignored. One might ask if adding -not will not make all other files hidden by -prune reappear, and the answer is no. This is then grouped as a single expression with the escaped parenthesis, and prefixed with -not which will make find skip anything that was matched by that expression. Inside \( and \) is an expression that will match exactly build/external (see important note above), and will, on success, avoid traversing anything below.

See note if you'd like a better understanding.
#LINUX FIND DIRECTORY BY NAME FULL#
If this sentence confuses you just make sure to use full paths through out the whole command like this: find /full/path/ -not \( -path /full/path/exclude/this -prune \). Important Note: the paths you type after -path must exactly match what find would print without the exclusion. I find the following easier to reason about than other proposed solutions: find build -not \( -path build/external -prune \) -name \*.jsįind build -not \( -path build/external -prune \) -not \( -path build/blog -prune \) -name \*.js
