I am trying to write a for loop in Bash shell. This is what I came up with:
for i in {0..20..5}
do
echo "Number: $i"
done
However the output is:
Number: {0..20..5}
I also tried this code:
N=10
for i in 1 2 3 4 5 .. $N
do
echo "Welcome $i times"
done
But in this case too, the output is:
Welcome 1 times
Welcome 2 times
Welcome 3 times
Welcome 4 times
Welcome 5 times
Welcome .. times
Welcome 10 times
I want to write a for loop where I can take the limits as well as the increment or decrement values.
This is the full script:
#! usr/bin/bash
N=10
for i in 1 2 3 4 5 .. $N
do
echo "Welcome $i times"
done
for i in {0..20..5}
do
echo "Number: $i"
done