How to find directory containing specific files or directories?
I'm looking for a one-line command that find multiple files or directories contained by a single directory.
foo -> bar
-> baz
-> quux
temp -> bar
I'm looking to only find foo
because it contains bar
, baz
, and quux
, but not find temp
.
Due to other reasons, I have to use tcsh
for this.
Any suggestions?
Solution 1:
This should do what you want and works with the data provided
find . -type d -exec test -e '{}'/bar -a -e '{}'/baz -a -e '{}'/quux \; -print
It basically finds directories then checks to see if they contain the relevant files. If they do it prints the name. It works in bash and tcsh.