Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null value for case statement 1

Status
Not open for further replies.

goldenradium2001

Technical User
Mar 22, 2002
91
US
Is there any way to specify a null value for a case statement? For example here's my statement:

case "$var" in
1) echo "Correct. The answer is 1."
;;
<null>) echo &quot;You need to enter a value.&quot;
;;
*) echo &quot;Incorrect answer.&quot;
;;
esac

Thanks in advance!
 
Hi,

i believe a null is represented by the characters ''

e.g.

#!/bin/ksh

var=$1

case $var in
1) echo &quot;YES&quot;;;
2) echo &quot;NO&quot;;;
'') echo &quot;INCORRECT&quot;;;
*) echo &quot;NOPE&quot;;;
esac

good luck!

br,

raisin96
 
Thanks, actually &quot;&quot; worked but at least I knew what to start with!

Thanks again!
 

an other way:
case x$var in x) #empty var
;; xx) # var value == x
;; esac -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top