From the shell, I'd like to recursively search a directory for a given glob pattern. But I want to use set-braces-syntax in my pattern:
find ~/path/to/dir -name '*.{h,m}'
Here I'd like to recursively find all .h
and .m
files located anywhere under the given path.
I gather from reading the glob documentation these 'set' patterns using curly ({
) braces are called
csh(1) style brace expressions
However, my tests using bash and tcsh on macOS 12.3.1 reveal that this set-syntax is not supported by find
. Reading the find man page, I don't see any mention of support for this syntax (maybe I missed it).
How can I accomplish this using this specific 'set' or 'csh-style' curly brace syntax? I'm less interested in work-arounds that use a different syntax.
… \( -name '*.h' -o -name '*.m' \)
. Call it a work-around, but it's a legitimate (and POSIX) way.shopt -s globstar nullglob; for f in ./**/*.{h,m}; do printf '%s\n' "$f"; done
. This is not an answer because from the title I deducefind
is required.