The UNIX and Linux Forums  

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


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
while loops nymus7 Shell Programming and Scripting 4 03-31-2006 09:59 AM
While loops and awk Loriel Shell Programming and Scripting 1 10-26-2005 09:26 AM
two loops big123456 UNIX for Dummies Questions & Answers 2 10-11-2005 12:08 AM
While Loops vdc UNIX for Dummies Questions & Answers 4 05-10-2005 05:55 AM
Loops mariner UNIX for Advanced & Expert Users 2 07-01-2004 04:50 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-05-2001
Registered User
 

Join Date: Sep 2001
Location: Canada
Posts: 12
loops?

hello....very new user to unix...and i have a question..i am not sure if there is such a thing


For example...the user is asked if he likes Bananas....if he says yes....

echo You like Bananas $name
at the end of the script it echos all that the user has entered so they can read it....
but if the user if the user says no it still comes ou

you like bananas $name

is there a loop structure so that if they put no then at the end the script it will say they dont like bananas....I am not sure if you will understand this but I dont know how else to explain it...
Thanks!!
Forum Sponsor
  #2  
Old 11-06-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Well, if I understand what you are asking, there are actually several ways to do this...
Code:
#!/bin/sh
negative=""
echo "Do you like bananas?"
read banana
case $banana in
     Y*|y*) negative="" ;;
     N*|n*) negative="do not " ;;
            *) echo "Huh?" ; exit 1 ;;
esac
echo "You said you ${negative}like bananas"
exit 0
That is persoanlly how I would do it.
Like I said though, there are several ways to do it.

I sure hope that wasn't homework...
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0