The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-07-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
Unhappy if statement in a while loop

#!/usr/bin/ksh
echo Please enter
while read n
do
echo $n >> datafile
done

question:

How can I enject an if statement that if the users enter 0 (zero) the program will exit?

this is what I have but not working

#!/usr/bin/ksh
echo Please enter number
while read n
do
if $n=0
then
exit
else
echo $n >> datafile
fi
done


Thanks!