From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078705511227.tru64-unix-managers.marc@archive.invalid> From: "Spalding, Steve" Date: Wed, 01 Apr 1998 13:59:45 +0000 To: tru64-unix-managers Subject: SUMMARY: inequalities in a case statement in ksh X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078705511227 The original message is posted below. I got a couple of good ideas from George Guethlein and Wayne Sweatt that I was able to go off of. Here is an excerpt of what I responded with to George: "When ksh performs it's compare operation (especially in the case statement) it compares string types and not numeric types. When you perform a compare in a case statement using numbers, it (ksh) only recognizes the first digit of a multi-digit number. Here's an example of what I mean: junk=19 case $junk in [1-9]) echo "between 1 and nine" ;; [10-19]) echo "between 10 and 19" ;; [20-29]) echo "between 20 and 29" ;; esac Here, ksh doesn't recognize any number over 9 because any such number over 9 consists of two characters. Give it a try. Here's what I've come up with to take care of the problem (building on George's solution): junk=13 case $junk in [1-9]) echo "between 1 and nine" ;; 1[0-9]) echo "between 10 and 19" ;; 2[0-9]) echo "between 20 and 29" ;; esac Here, two digit numbers (in the 10 through 29 range) are recognized because I've told ksh to compare two specific characters in each case. If I wanted to go into the 100's range with my numbers, I'd have to use a case statement that's something like this: case $junk in [1-9]) echo "between 1 and nine" ;; 1[0-9]) echo "between 10 and 19" ;; 2[0-9]) echo "between 20 and 29" ;; 3[0-9]) echo "between 30 and 39" ;; 4[0-9]) echo "between 40 and 49" ;; 5[0-9]) echo "between 50 and 59" ;; 6[0-9]) echo "between 60 and 69" ;; 7[0-9]) echo "between 70 and 79" ;; 8[0-9]) echo "between 80 and 89" ;; 9[0-9]) echo "between 90 and 99" ;; 1[0][0-9]) echo "between 100 and 109" ;; 1[1][0-9]) echo "between 110 and 119" ;; esac" As of yet I still do not know how to use any kind of mathematical inequality (using the >, <, -gt, or -lt signs) in a ksh case statement, but the above solution solves my immediate problem. Regards, Stephen Spalding Associate System Administrator sspaldin@mem-ins.com Missouri Employers Mutual Insurance > ---------- > From: Spalding, Steve[SMTP:SSPALDIN@mem-ins.com] > Sent: Tuesday, March 31, 1998 14:39 > To: 'alpha-osf-managers@ornl.gov' > Subject: inequalities in a case statement in ksh > > Hello all! > > Since my question earlier today went so well, I thought that I would > try > another. I'm writing a script file using a case statement, and I want > to > use inequalities with it but don't know how. Here is what I have right > now: > case "$capacity" in > [93 - 96] if [ $severity -lt 1 ];then > severity=1 > fi #if [ $severity -lt 1 ];then > ;; > [97 - 99] if [ $severity -lt 2 ];then > severity=2 > page=true > fi #if [ $severity -lt 2 ];then > ;; > 100) if [ $severity -lt 3 ];then > severity=3 > page=true > fi #if [ $severity -lt 3 ];then > ;; > esac #case "$capacity" in > > Let's say that in the last case I wanted to catch any value above 100 > instead of just 100; how would I set that up? Here is what I have > tried > using: > > > 100 if [ $severity -lt 3 ];then > > [ > 100 ] if [ $severity -lt 3 ];then > > [ -gt 100] if [ $severity -lt 3 ];then > > but nothing seems to want to work. Any ideas? > > Thanks! > > PS - Lawrence Decker - I tried responding to your email earlier, but I > keep getting this text in a returned mail message: > > Your Message > To: 'ldecker@pbchcd.state.fl.us' > Subject: FW: Pop up message > Was not delivered for the following reasons: > Delivery failed to SMTP:ldecker@pbchcd.state.fl.us. > Reason: 0 (transfer failed) > diagnostic: 0 (OR name (Email address) unrecognized). > MSEXCH:IMS:MEM:EXCH1:MEM_CO_NT1 3902 (000B0981) Host Unknown. > > > Stephen Spalding > Associate System Administrator > sspaldin@mem-ins.com > Missouri Employers Mutual Insurance >