How do I exclude a directory when using `find`?

If -prune doesn’t work for you, this will:

find -name "*.js" -not -path "./directory/*"

Caveat: requires traversing all of the unwanted directories.

Leave a Comment