I need to run a bash script on a list of subjects. I would like to build a while loop, that runs on multiple subjects at the same time. However, the commands within the loop must run sequentially.
May you please confirm me that a sintax like this would do the job?
file="subjects.txt"
foo () {
command $subj etc
command 2 $subj etc
command 3 $subj etc
}
while read subj; do foo "$subj" &
done <$file
Thank you in advance for your help.
Ramtin