find a folder not containing a specific file
I need to find, using the 'find' command, a file not containing a specific file.
It is easy to find folders containing the file, using find "x/x/x/x/" -maxdepth N -mindepth N -type f -iname '*filename.ext' The min- and max-depth params are there because this file will always appear at a certain level in the (rather deep) folder hierarchy (the bottom, actually). How would I identify folders at this depth that do not contain this file? I cannot just negate the 'name' parameter, because there are other files having arbitrary names that reside within the same folders as 'filename.ext' that would match the pattern. Thanks! |
Assuming N is 3:
Code:
$ find . -mindepth 3 -maxdepth 3 -type d -execdir bash -c 'ls {}/*filename.ext >/dev/null 2>&1 || pwd' \; |
wow.
It makes perfect sense, thank you. That should be in a FAQ somewhere ;) |
All times are GMT -5. The time now is 02:57 AM. |