Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-15-2007, 01:04 PM   #1
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" ;;


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

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

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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:
case $TYPE in
  "") echo "No" ; exit 0 ;;
   *) echo "Yes" ;;
Old 03-15-2007, 02:19 PM   #3
Registered: Feb 2007
Posts: 41

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


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 05:33 PM
How do I use an If statement within a case in a Shell script?? crazygyhrous Programming 7 01-03-2006 07:41 AM
problematic case statement alaios Programming 4 08-24-2005 10:05 AM
KSH Scripting case statement..... ']['HeBroken Programming 1 12-10-2004 11:38 AM
bash'ed by case statement??? 3inone Programming 2 04-29-2004 05:52 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:12 AM.

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