Created
March 10, 2015 19:50
-
-
Save jesusgoku/afc0e4a2accc74ea65f4 to your computer and use it in GitHub Desktop.
Exclude directories with find command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use the prune switch, for example if you want to exclude the misc | |
# directory just add a -path ./misc -prune -o to your find command: | |
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 | |
# Here we exclude dir1, dir2 and dir3, since in find expressions it is an action, | |
# that acts on the criteria -path dir1 -o -path dir2 -o -path dir3 | |
# (if dir1 or dir2 or dir3), ANDed with type -d. Further action is -o print, just print. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment