The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
exit out of a while loop with error sigh2010 Shell Programming and Scripting 2 03-03-2009 04:51 PM
how to exit a while true loop Noob e Shell Programming and Scripting 5 08-26-2007 03:44 PM
Method to exit a for loop Rohini Vijay Shell Programming and Scripting 2 11-01-2006 05:56 AM
while loop exit Terrible Shell Programming and Scripting 3 07-28-2006 06:20 PM
csh exit while loop on keystroke seg Shell Programming and Scripting 7 12-29-2004 11:45 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-27-2009
gumbi17 gumbi17 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 2
Exit from loop only when selected

I am trying to get my program to exit when the answer to my question is positive, if I am asking if the answers are correct in the entries that the user inputted and the user says no how do I then have it exit? If they say everything is correct then it continue into the program, I think I am close but my syntax maybe off.

Stop=N
while [[ $Stop = "N" ]]
do
read -p "Are you sure you inputed all numbers correctly? (y/n)" Stop
exit
done
  #2 (permalink)  
Old 09-27-2009
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 761
Something like this perhaps?

Code:
while read -p "Are you sure all your numbers are correct? (y/n) " correct; do
  case $correct in
    y|yes) break ;;
    n|no)  exit ;;
    *)     echo please select yes or no... ;;
  esac
done

  #3 (permalink)  
Old 09-27-2009
gumbi17 gumbi17 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 2
Thanks worked great!
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0