Scott Pearce
Scott Pearce

Reputation: 207

How to add more than 1 number in a loop in Bash script?

So I have this loop:

for ((i=100;i<1001;i++));
do
     echo $i
     sleep 1
done

I want to know how I can add 10 every time the loop repeats instead of adding 1. So I want the loop to look something like this: 110 120 130 140 and keep going until it reaches the limit or stopped! Thanks

Upvotes: 0

Views: 308

Answers (1)

Ainz Titor
Ainz Titor

Reputation: 1557

for ((i=100;i<1001;i+=10));
do
     echo $i
     sleep 1
done

Simply change ++ to += 10

Upvotes: 1

Related Questions