Bash recursively execute a command on each directory
bash, console, linux
Solution
You just need a trailing slash on the glob:
for d in */; do # only match directories
( cd "$d" && svn up ) # Use a subshell to avoid having to cd back to the root each time.
done
Problem
I have a directory with many subdirectories inside, i want to execute a command on each of those subdirectories. What i want to do is run 'svn up' this is what i have tried so far ``` find . -type d -maxdepth 1 -exec svn "up '{}'" \; ``` and ``` for dir in * do cd $dir; svn up; cd ..; ``` None of them works so far (I have tried many things without luck)