Showing posts with label Some loop examples in bash scripting for and while. Show all posts
Showing posts with label Some loop examples in bash scripting for and while. Show all posts

Wednesday, November 16, 2022

Some loop examples in bash scripting for and while

 
for i in  1 2 3 4 5
do
echo "Maharshi"
done

for i in  {0..10..5}
do
echo -e "Maharshi\t$i"
done

for i in  {10..0..-5}
do
echo -e "Maharshi\t$i"
done

for i in {1..10}
do
printf "%s\n%s\n" "Galgotias" "UNiversity";
done


for i in $(seq 1 10)
do
printf "%s\n%s\n" "Galgotias" "UNiversity";
done


for i in $(seq 1 2 10)
do
printf "i is %d\n" "$i";
done

for i in $(seq 10 -2 1)
do
printf "i is %d\n" "$i";
done

for((i=4;i<10;i++))
do
echo "Maharshi";
done

echo "enter a number";
read number;
if (((number < 10))  &&  ((number > 1)))||(((number<100))&&((number>90)))
then
echo $number;
fi

i=0
while ((i < 5 ))
do
echo "maharshi";
i=$(($i+1));
done

arithmatic expansion

i=15;
i=$(($i*5));
echo $i;