Script to execute arbitrary command on each Git project in a directory
Instead of using find and testing whether .git is a directory, you could make a simplification:

for git_dir in */.git ; do
(
    cd "$git_dir/.." &amp;&amp;
    pwd &amp;&amp;
    $@
    echo
)
done


Admittedly, this causes an error when .git exists but is not a directory:


-bash: cd: blah/.git/..: Not a directory



… instead of silently skipping that entry as your script does.  But I would consider the error message to be a feature, not a bug.  =)  Note my use of &amp;&amp; after cd to ensure that the command is not executed if the cd fails.  (That could happen if the directory lacks the executable bit.)

If you wanted to support compound commands like echo hey; echo bye, you could use eval $@.  Using eval feels a bit risky, but it's OK if the script is for your own personal use and won't be attacked.