I have a directory tree that I want to search recursively for all files of a certain type (for example all
.jpg's), but I only want to list these files if they are at the bottom of a directory tree.
As an example if my tree looks like:
home root f1 f2 f3 f11 f22 f33 f111 f222 f333
and all folders have
.jpg's, I only want to list the
f333, and so on, and ignore the ones in the higher up folders.
I know that I can use a find command (like
find . -name "*.jpg") to get a listing of all
.jpg's in the entire tree, but I'm not sure how to limit it to only the bottom most folders without doing something like
grep'ing the results to filter for
333's which isn't really feasible as I have hundreds of folders and I don't know what the last level folders might be named for all of them individually.