LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 04-12-2002, 04:47 PM   #1
bspicer
LQ Newbie
 
Registered: Apr 2002
Posts: 26

Rep: Reputation: 15
Script and If Statement


How can I check for both uppercase Y and lowercase y

echo -e "Is this correct (y/n): \c "
read ans
if [ "$ans" = "y" ]
then


fi

thanks
 
Old 04-12-2002, 06:36 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 21,592
Blog Entries: 47

Rep: Reputation: 1408Reputation: 1408Reputation: 1408Reputation: 1408Reputation: 1408Reputation: 1408Reputation: 1408Reputation: 1408Reputation: 1408Reputation: 1408
Re: Script and If Statement

Spose there's an easier way but I haven't found it (74 chars):
if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then echo "ok"; else echo "you made a boo boo"; fi

You could also use a simple case statement (72 chars):
case "$ans" in
y|Y)
echo "ok";;
*)
echo "you made a boo boo"
exit 1;;
esac

Last edited by unSpawn; 04-12-2002 at 06:38 PM.
 
Old 04-15-2002, 06:02 AM   #3
bspicer
LQ Newbie
 
Registered: Apr 2002
Posts: 26

Original Poster
Rep: Reputation: 15
Thank you..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to close 'else' statement block in bash script servnov Linux - General 9 11-12-2004 03:53 PM
For Statement bendeco13 Linux - General 6 10-31-2004 05:31 PM
If Statement junjem0702 Programming 4 08-23-2004 09:49 AM
Bash script problems with "if" statement adz Programming 2 05-22-2004 03:34 AM
Need help adding an IF / ELSE statement to my Bash Script Relix Linux - General 1 08-01-2002 02:03 PM


All times are GMT -5. The time now is 11:50 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration