For loops in shell scripting

By | November 6, 2013

Loops contains the code that will execute until the loop ends

———————————-
Syntax:

for arg in [list]

do
commands

done

———————————-

for arg in “$mydoubts1 $mydoubts2 “……”$mydoubts N”

*) in pass 1 of the loop,arg=$mydoubts1
.
.
.
8) In pass N of the loop,arg= $mydoubts N

For Loop Example

#!/bin/bash
# Listing the states

for dispstate in kerala,karnataka,tamilnadu,goa,Andhra

do

echo $dispstate