run serveral loops simultaneously?

Hello everyone, say I have the following script, which contains serveral loops, if I run the script, it executes the loop one by one (after the a loop, it goes to b loop, then c, then d)

I figured I should be able to run all the loops at same time, but I don't know how, can anyone help a little bit here? thanks!

for file in `ls a*`; do commanda ; done

for file in `ls b*`; do commandb ; done

for file in `ls c*`; do commandc ; done

for file in `ls d*`; do commandd ; done

The best location for advanced topics! Special Characters

Anyways, that link will show you, but here is the code:

for i in 1 2 3 4 5 6 7 8 9 10            # First loop.
do
  echo -n "$i "
done & # Run this loop in background.
       # Will sometimes execute after second loop.

That will allow you to put the loop in the background (notice the & after done).
That should work!
[/COLOR]

Not only is ls unnecessary, but it will break your script if any of the filenames contain spaces.

for file in a*; do commanda ; done &
for file in b*; do commandb ; done &
for file in c*; do commandc ; done &
for file in d*; do commandd ; done &

Or:

for l in a b c d
do
   for file in "$l"*; do command$l; done *
done