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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Loops / IF Statements

Status
Not open for further replies.

felix001

Technical User
Nov 15, 2008
102
GB
i need to write a scipt which is based on a for loop. Within the for loop i require most of the script such as if statements and also a while loop.

The problem is when a if statement is reached i.e the RC is nto equal to 1 . I want the current loop to exit and then for it to start the next loop.

an example is
Code:
for i in `ls`
do
      mv -f $i /tmp
if [ $? ! 0 ] 
   then 
   exit 1
else 
   Echo $i moved to /tmp
   fi
done

A+, N+, CCNA, CCSA, SNPA
- Keeping You in the Know
 
Simply use the continue instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top