Hi All,
I want to know if there is any way to exit from both the parent and child loop simultaneously without adding any kind of conditional statement.
********************************************************
#!bin/ksh
a=5
if[[ $a -gt 5 ]]
then
echo "a=5 and not went to else cdn."
else
if [[ $a==5 ]]
then
echo "a=6"
fi
echo "a=5 and not worked"
fi
echo "got it"
********************************************************
Once the program prints "a=6" it should print "got it".
Will any thing work here without going for label,goto command.
I tried with break but it din't work at all.
Please suggesst me your views.

/Nandoo.

Recommended Answers

All 2 Replies

Hmm... not exactly sure because I program in a structured language (C++). I definitely agree that you shouldn't use a GOTO command.

I think you should use a switch or while statement, and then break when you're done. This would allow you to keep "structured" programming, while avoiding the GOTO statement.

Your logic doesn't make any sense to me...

You want to get to the "got it" statement - this does it.

#!bin/ksh
a=5
while [[ $a -gt 5 ]]
do
	echo "a=5 and not went to else cdn."

	if [[ $a==5 ]]
	then
		echo "a=6" 
	fi
	echo "a=5 and not worked" 
done
echo "got it"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.