# global - execute command in all subdirectories exec 3<&0 # save standard input find . -type d -print | # print all directory names while read dirname do (cd $dirname exec 0<&3 # restore standard input "$@" # run command ) done exec 3<&- # close file descriptor