Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

loops in shell script

#!/bin/bash
for i in 1 2 3 4 5
do
   echo "Welcome $i times"
done
-----------------------------------
#!/bin/bash
for i in {1..5}
do
   echo "Welcome $i times"
done
----------------------------------
#!/bin/bash
for i in {0..10..2}
  do 
     echo "Welcome $i times"
 done
------------------------------------
a=0
# -lt is less than operator
 
#Iterate the loop until a less than 10
while [ $a -lt 10 ]
do
    # Print the values
    echo $a
     
    # increment the value
    a=`expr $a + 1`
done
 
PREVIOUS NEXT
Tagged: #loops #shell #script
ADD COMMENT
Topic
Name
6+8 =