We help IT Professionals succeed at work.

# case statement Linux

on
327 Views
How do I make a case statement that will allow me to show a range from 90 to 100? I have tried a lot of combinations and nothing worked yet. I am using Darwin.
This is an example of what I have been working on.

case \$blah in
[9-1][0-00]) echo "statement" ;;
Comment
Watch Question

## View Solution Only

Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
if think a normal
if ( \$blah >=  90 &&  \$blah <=100 )
would be more efficient in the code...

Commented:
Agreed
Top Expert 2005

Commented:
Rather

if [ \$blah -ge 90 -a \$blah -le 100 ]; then
echo statement
elif [ \$blah -gt 100 ]; then
echo "greater than 100"
fi

Commented:
I thought about doing that but case is how I have to do this.
Top Expert 2005

Commented:
I assume bash

case \$blah in
9?|100) echo "OK"
esac
Top Expert 2005
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)

Commented:
I also want to thank the rest who took time to do the if statements. One more question how do I do 0-60 without a car :) I know how to do 60-69 [6-6][0-9], and other numbers like that but I am having a hard time with the zeros.
Top Expert 2005

Commented:
[0-9]|[1-5][0-9]|60

Commented:
Thank you Ravenpl. That works but still a bit confused. The first bracket goes 0-9, then the second and third show 10-59, and the last shows 60, am I correct?
Top Expert 2005

Commented:
Yes You correct. The | means simply OR, so there ae three patterns to mach
Unlock the solution to this question.