![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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
Like I said though, there are several ways to do it. I sure hope that wasn't homework... |
||||
| Google The UNIX and Linux Forums |