You want to run a shell command in many directories. For example, in my case, I wanted to execute a shell command in lots of directories(approx. 200) to clean up build files.
Writing a for-loop and running it on the shell did the trick for me.
for d in ./*/ ; do (cd "$d" && mvn clean); done
The above for-loop would run
cd "$d" && mvn clean in each item of the directory list defined by the path
$d holds the directory name. You can be creative in defining the list of directories using a complex glob as well.
I hope this helps you as well.