Home » » Shell Scripting Tutorial For Beginners Xv - Spell Loops

Shell Scripting Tutorial For Beginners Xv - Spell Loops


#!/bin/bash # land loops n=1  # root way echo "----while loops------first way-------------------" while [ $n -le x ] do     echo "$n"     (( n++ )) done   # 2nd way n=1 echo "----while loops------second way-------------------" while (( $n <= x ))   do     echo "$n"     (( ++n )) done  # tertiary way n=1 echo "----while loops------third way-------------------" while [ $n -le x ] do     echo "$n"     n=$(( n+1 )) done 
output:
test@test: /Desktop$ ./hello.sh  ----while loops------first way------------------- 1 2 3 4 5 6 7 8 9 10 ----while loops------second way------------------- 1 2 3 4 5 6 7 8 9 10 ----while loops------third way------------------- 1 2 3 4 5 6 7 8 9 10 test@test: /Desktop$  

0 comments:

Post a Comment

Search

Blog Archive