Bash find command directory exclude

Exclude Directories in Bash find Command

Introducing how to exclude folders and directories in the find command of the Linux Bash command line. For example, if you want to exclude the ./misc folder/directory

Shou Arisaka
1 min read
Nov 15, 2025

Introducing how to exclude folders and directories in the find command of the Linux Bash command line.

For example, if you want to exclude the ./misc folder/directory, use ./misc -prune -o. Hereโ€™s an example:

find . -path ./misc -prune -o -name '*.txt' -print

Here is an example with multiple directories:

find . -type d \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -o -print

Share this article

Shou Arisaka Nov 15, 2025

๐Ÿ”— Copy Links