Gnu find

From wikinotes

Search files and directories.
The man page is very good and has several examples.
This page is essentially a cookbook.

Also see bsd find.

Documentation

man find https://man.archlinux.org/man/core/findutils/find.1.en

Recipes

Find files by bitmask

Unfortunately, different between gfind and bsd find.

# files with the executable bit set for user AND group AND other
find . -type f -111

# files with the executable bit set for user OR group OR other
# ('+111' on bsd-find)
find . -type f /111

Suppress stderr in subshell

results=($({ find . -name .git; } 2>/dev/null))

Exclude Directories while searching for files

find . \
  -path ./exclude_me -prune -o  `# exclude ./exclude_me and subdirs` \
  -type f -name '*.txt'         `# rest of your find expression`
# 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'