Operating System - HP-UX
1834299 Members
2110 Online
110066 Solutions
New Discussion

How to get out from do/done , not from shell...

 
SOLVED
Go to solution
Vlad_11
Frequent Advisor

How to get out from do/done , not from shell...

Hi
I"m using pretty simple "while" to browse DATEFILE to find match, it could be in the middle of it, and I need to stop reading it if match occured. If I'm using "exit" I'm out of shell, but I need just to be out of do/done and go on with further statements:

Thanks
VMo


while read FMONTH FDATE
do
if [ $MONTH = "$FMONTH" ]; then
echo "$MONTH $FMONTH match match match"
SW="GOOD"
exit #!??????????????????
fi
done < ${DATEFILE}

echo "This is end of shell........."
beer or not beer
2 REPLIES 2
curt larson_1
Honored Contributor
Solution

Re: How to get out from do/done , not from shell...

break [n]

break exits from the smalles enclosing for, while, until, or select loop, or from the nth enclosing loop if you specify n. Execution continues with the command immediately following the loop(s). of course n is an integer greater then or equal to 1. default is 1.
James A. Donovan
Honored Contributor

Re: How to get out from do/done , not from shell...

MATCHED=0
while ! $MATCHED
do
while read FMONTH FDATE
do
if [ $MONTH = "$FMONTH" ]; then
echo "$MONTH $FMONTH match match match"
SW="GOOD"
MATCHED=1
fi
done < ${DATEFILE}
done

other stuff....

echo "This is end of shell........."
Remember, wherever you go, there you are...