The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



Thread: Scripting help
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-14-2008
tiney83 tiney83 is offline
Registered User
 

Join Date: May 2008
Posts: 3
Scripting help

Hi,
I have an assignment for my Unix class to write a program asking a user to enter a number. the user then chooses an option from a menu of whether they want to count down to zero from the number they entered, or count up from zero to the number. The error i keep getting is binary operator expected for lines 9 and 14 , than when i change that it says unary operator expected. Also I want to know if I coded this whole thing corretly. any ideas?

Code:
echo "Enter a number"
read $number
echo "What do you want to do to this number?"
echo "Enter d, to count down to zero"
echo "Enter u, to count  up from zero"
read choice
case $choice in
d) while [ "$number" \>= "0" ]
do
echo $number
$number = `expr $number - 1`
done;;
u) while [ "0" \<= "$number" ]
do
echo $number
$number = `expr $number + 1`
done;;
esac
echo "bye"
~
Reply With Quote
Forum Sponsor