I have a following line:

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

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 Answer 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 

Try the same without the double quotes!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .