LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-15-2007, 12:04 PM   #1
baks
Member
 
Registered: Feb 2007
Posts: 41

Rep: Reputation: 15
case statement


Hi, would anyone know whether I could check to see whether any input has been entered via a case statment ?

echo "type"
read TYPE

case $TYPE in
[-z)echo "type"
read TYPE ;;
*) echo "YES YES" ;;

esac

I would like to check if nything has been entered but using a case statement.

Thank you
 
Old 03-15-2007, 12:25 PM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 614Reputation: 614Reputation: 614Reputation: 614Reputation: 614Reputation: 614
read waits for input, so if you've reached the case statement you *do* have input, thopugh it may have just been the ENTER key. You can check first for a null string as input:
Code:
case $TYPE in
  "") echo "No" ; exit 0 ;;
   *) echo "Yes" ;;
esac
 
Old 03-15-2007, 01:19 PM   #3
baks
Member
 
Registered: Feb 2007
Posts: 41

Original Poster
Rep: Reputation: 15
Thank you very much.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Does CGI/PERL have a Select Case Statement? craig467 Programming 2 02-16-2007 04:33 PM
How do I use an If statement within a case in a Shell script?? crazygyhrous Programming 7 01-03-2006 06:41 AM
problematic case statement alaios Programming 4 08-24-2005 09:05 AM
KSH Scripting case statement..... ']['HeBroken Programming 1 12-10-2004 10:38 AM
bash'ed by case statement??? 3inone Programming 2 04-29-2004 04:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:37 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration