Gnu find
From wikinotes
Search files and directories.
This page is essentially a cookbook.
Also see bsd find.
Recipes
Suppress stderr in subshell
results=($({ find . -name .git; } 2>/dev/null))Exclude Directories while searching for files
# search for *.txt files, not recursing into ~/.cache find . \ -not \( -path $HOME/.cache -prune \) \ -name '*.txt'Another less efficient alternative, that must glob match all files
find . \ -not -path $HOME/.cache/* \ -name '*.txt'