Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

breaking out of one loop and skipping one iteration

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am writing a shell script in which I am using 2 while loops. I want to break out the inner while loop and skip the current iteration of the outer while loop. Here is a pseudo script. Can anyone suggest a solution.

while [ some condition ]
do
statement 1
statement 2
while [ some condition ]
do
if [ some condition ]
then
# I want to goto statement 1
# how to implement this -- should I put
# break but this will
# merely go to statement 3 #' which I dont want to execute. In
# other words, break out of the inner loop and
# skip only the current iteration of the outer loop
#
else
# Skip the current iteration of the inner # while loop
# I think this can be done by continue isn't # it?..so here goes
continue
fi
done
statement 3
statement 4
done


Any help would be appreciated

 
How does this sound?

After the inner loop, check the same "some condition" that you're checking *in* the inner loop and, if true, break out of the outer loop.
Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top