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   f333and all folders have .jpg's, I only want to list the .jpg's in f111/f222/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 111/222/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.
How can I list all files, but only in directories that have no subdirectories?
linux;files;find
You can do this in two steps:find . -type d -links 2 -print0 | xargs -0 -I{} find {} -name \*.jpgThe first command lists all directories without any subdirectories (since each subdirectory adds one to the link count, while an empty directory has two). The second invokes find manually on each of these results.