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 -->
  #4 (permalink)  
Old 05-14-2008
rubin's Avatar
rubin rubin is offline
Registered User
 

Join Date: Nov 2007
Posts: 177
As Smiling Dragon mentioned it's against the forum's rules posting homework..., but at least you have put some effort:

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" -ge 0 ]
do
echo $number
number=`expr $number - 1`      # no spaces here before/after = sign
done;;
u) while [ 0 -le "$number" ]
do
echo $number
number=`expr $number + 1`
done;;
esac
echo "bye"
~

Last edited by rubin; 05-14-2008 at 04:59 PM. Reason: removed extra $$
Reply With Quote