function look_for_update() { if [[ $1 == ./.* ]] || [[ $1 == "." ]]; then return fi printf -v quotedFile '%q' "$1" if [[ -f $quotedFile/update.sh ]]; then echo "Switch to subdir $1 and run update.sh" cd "$1" bash -c ./update.sh else echo "Pull $quotedFile" cd "$1" git pull fi } export -f look_for_update find . -maxdepth 1 -type d -exec bash -c 'look_for_update "$0"' {} \; read -p "Press return"