How to exclude a folder in find command on a Mac

In order to exclude a folder with find command on a mac, you need to use to command:

-path ./path-to-exclude -prune -o

E.g. to find .txt files in the current folder without descending into a folder called foo, use the following command:

find . -path ./foo -prune -o -name '*.txt'


linux – Exclude directory from find . command – Stack Overflow. [17/01/2017].

Leave a Reply

Your email address will not be published. Required fields are marked *