We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Linux Shell
- Bash
- Looping with Numbers
- Discussions
Looping with Numbers
Looping with Numbers
Sort by
recency
|
96 Discussions
|
Please Login in order to post a comment
limit=50
Define a variable to start the loop
num=1
Loop until num reaches the limit
while [ limit ] do # Print the current value of num echo $num
done
echo 1; echo 2;echo 3;echo 4;echo 5;echo 6;echo 7;echo 8;echo 9;echo 10;echo 11;echo 12;echo 13;echo 14;echo 15;echo 16;echo 17;echo 18;echo 19;echo 20;echo 21;echo 22;echo 23;echo 24;echo 25;echo 26;echo 27;echo 28;echo 29;echo 30;echo 31;echo 32;echo 33;echo 34;echo 35;echo 36;echo 37;echo 38;echo 39;echo 40;echo 41;echo 42;echo 43;echo 44;echo 45;echo 46;echo 47;echo 48;echo 49;echo 50
for i in {1..50} do echo $i done
for i in {1..50} do echo $i done