Maria F. answered 05/16/26
Computer Science & Programming Tutor| APCS, Java,Python,C++
Using for loop
for i in {100..1}
do
echo $i
done
Using while loop
i=100
while [ $i -ge 1 ]
do
echo $i
((i--))
done
Clarissa M.
asked 07/22/21Maria F. answered 05/16/26
Computer Science & Programming Tutor| APCS, Java,Python,C++
Using for loop
for i in {100..1}
do
echo $i
done
Using while loop
i=100
while [ $i -ge 1 ]
do
echo $i
((i--))
done
Inactive Tutor answered 07/22/21
try these...
#!/bin/bash
for (( c=1; c<=5; c++ ))
do
echo "Welcome $c times"
done
#!/bin/bash
for ((c=100; c>0; c--))
do
echo "Number $c Loop"
done
!/bin/bash
x=1
while [ $x -gt 1 ]
do
echo "Welcome $x times"
x=$(( $x - 1 ))
done
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.