2

I have a following line:

for length in "$(ls $OUT_SAMPLE)"
do $CODES/transform_into_line2.rb -c $OUT_SAMPLE -p 0 -f $length & 
done

So,it should parallelize the for loop but somehow it still runs it in a sequence. However, if I do following:

 $CODES/transform_into_line2.rb -c $OUT_SAMPLE -p 0 -f blabla.txt &  $CODES/transform_into_line2.rb -c $OUT_SAMPLE -p 0 -f blabla2.txt

It does run it in parallel. Why doesn't a for loop work?

1
for length in "$(ls $OUT_SAMPLE)"

should be rewritten

for length in $(ls $OUT_SAMPLE)

In fact you are looping on a single value.

You can verify the values you're looping on with:

for length in "$(ls $OUT_SAMPLE)" ; do
  echo x$length 
done

Try the same without the double quotes!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.