1

Let's suppose I have the following loop:

for i in {1..3}
do

mkdir $i

done

Since I have many other loops in the main code and I am going to change regularly the size of the sequence, I would like to define the start and end of the loop and use these variables in the for loop(s).

I tried this without success:

start=1;
end=1;

for i in {$start..$end}
do

mkdir $i

done

Any suggestion?

aaaaa
  • 141

1 Answers1

0

Variables aren't expanded inside brace expansion. Try this instead:

start=1;
end=10;

for ((i=$start; i<=$end; i++))
do
    mkdir "$i"
done
terdon
  • 242,166