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?

muru
  • 72,889

1 Answers1

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!

freedge
  • 121
  • 3