[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell Scripting Question



On Tue, Oct 30, 2001 at 06:48:42PM -0500, Sunny Dubey wrote:
> for $fruit in `cat /usr/fruits.txt` ; 
> 	do
> 		echo -n "Do you like $fruit"
> 		read ANS
> 		if [ -z $ANS ] ; then
> 		# NEED HELP WITH CODE HERE
> 		fi
> 	done
> 
> how can I be able to have loop repeat itself at the same iteration when the 
> "if -z" statement turns out to be ture??

Use another loop:

for $fruit in `cat fruits`; do
	while [ -z $ANS ]; do
		echo -n "Do you like $fruit"
		read ANS
	done
done

M



Reply to: