Something like the following is what I what I'm after,
but my code doesn't work, no matter how I escape {}
and +
;
find ./ -maxdepth 1 -type d -name '.*' -exec \
find {} -maxdepth 1 -type f -name '*.ini' -exec \
md5sum \{\} \\; \;
After seeing this Unix-&-Linux question, I found that the following code works, but it isn't nesting find as such, and I suspect there is a better way to do this particular job.
find ./ -maxdepth 1 -type d -name '.*' \
-exec bash -c 'for x; do
find "$x" -maxdepth 1 -type f -name "*.ini" \
-exec md5sum \{\} \;; \
done' _ {} \+
Is there some way to nest find -exec
without the need to invoke
a shell (as above), with all its whacky quoteing and escape constraints?
Or can this be done directly in a single find command, using a blend of its many parameters?
find
, but iffind
can't do this, then why isfind
so revered(?) as the tool-to-use for finding files?... I've subseqeuntly found thatfind ./ -maxdepth 2 -path '.*/*.ini' -type f -exec md5sum {} \+
works fine in my situation (jw013's reference to-prune
led me to this in the man page), but I wonder if it is a robust method(in genera). I've never really usedfind
(in less than a year of Linux) aslocate
has done almost all I need, so it's unknown territory. – Peter.O Aug 05 '11 at 06:08-path
test is exactly what I was going to suggest. With this, you should be able to do all that you want (sorry for the Ace Of Base association;) ) – rozcietrzewiacz Aug 05 '11 at 10:51