Running a command for multiple folders at once

Hi I have folders 1 to 24 (24 folders in total) and inside those folders I have the same file names. I have a command that I want to run but rather than do it individually I was wondering if there is a command to run them all at once.

Thanks

Phil

#!/bin/bash
cd /path
for dir in {1..24}
do
   cd $dir
   # command goes here
   cd ..
done

Without bash you have to use something like this for the "for" construct

for dir in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

The {1..24} also works with recent versions of ksh. And with any shell that recognizes basic Bourne shell syntax, your could also use:

for dir in [1-9] 1[0-9] 2[0-4]

and with bash and recent versions of ksh you could also use:

for ((dir=1; dir<=24; dir++))
do      ...
done

The external command seq 24 might come in handy.