This feels like it must have an obvious answer, but I haven't yet found one.
Consider this file structure:
A.tsx
B.tsx
dist/C.tsx
dist/D.tsx
src/E.tsx
src/F.tsx
src/G.js
src/component/H.tsx
src/component/I.tsx
src/component/J.js
I want to list all .tsx files in the directory src and all of its descendants.
This lists all .tsx files in src but not its descendants:
ls src/*.tsx
This lists all .tsx files in src's descendants, but not src itself:
ls src/**/*.tsx
Is there a way to glob all .tsx files in src and its descendants in one pattern?
You need to ensure the
globstaroption is enabled, or else**is just interpreted as two adjacent*patterns, each of which will match 0 or more characters, so it's equivalent tosrc/*/*.tex, which must match some directory undersrc.should work.
Note that you need
bash4 or later to useglobstar. If you are using the system-providedbashon macOS (which is version 3.2), you'll need to install a recent version ofbashyourself. (Or switch tozsh.)