Two application types come to my mind where shell loops are not considered to be the best approach. The first is data processing; many tools (like sed, awk, perl, etc.) do the loop implicitly and much more performant. The second is (like in your sample code), where some code is executed for a set of files, where find with the -exec switch can also already execute commands (also a shell) with less problems and overhead. There are probably more cases, but those two mentioned should already be enlightening. That said; shell loops are not inherently bad, or somesuch. Just take other options (like the two mentioned) into your consideration.
find /etc/postinstall -name '*.sh' -exec bash -c 'echo Runing {} ...; "{}" ; mv "{}" "{}.done"' \;– Costas Apr 25 '15 at 22:38-exec sh -c 'for script do...' sh {} +here or (GNUly):find ... -printf 'Executing %f\n' -exec {} \; -exec mv {} {}.done \;(which would run the mv only if the script succeeds). – Stéphane Chazelas Apr 26 '15 at 08:43find's probably overkill - recursing a tree and executing unknown scripts - likely as root - is crazy. Iffindcalled a script which altered the mount tree it could go really bad. And renaming files in /etc should be avoided. As I see it the op should handle only files named to some expected conformity - like the common 1-99 prefixes - and just dot each in the order theyre globbed in a for loop - each in its own subshell if need be. I believe that's something like what he intends to do now anyway. – mikeserv Apr 26 '15 at 10:44