#!/usr/bin/env sh initialdir="$PWD" for dir in *; do if [ -d "$dir" ]; then echo "$dir" cd "$dir" "$@" cd "$initialdir" fi done