Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

case statement Linux

Posted on 2007-10-13
10
Medium Priority
?
276 Views
Last Modified: 2013-12-26
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" ;;
0
Comment
Question by:ourbhoy
10 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20071072
if think a normal
if ( $blah >=  90 &&  $blah <=100 )
would be more efficient in the code...
0
 
LVL 6

Expert Comment

by:Kieranwest
ID: 20071258
Agreed
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20071336
Rather

if [ $blah -ge 90 -a $blah -le 100 ]; then
 echo statement
elif [ $blah -gt 100 ]; then
 echo "greater than 100"
fi
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ourbhoy
ID: 20071808
I thought about doing that but case is how I have to do this.
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20071823
I assume bash

case $blah in
 9?|100) echo "OK"
esac
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 2000 total points
ID: 20071840
correction
case $blah in
 9[0-9]|100) echo "OK"
esac
0
 

Author Comment

by:ourbhoy
ID: 20071911
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.
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20071921
[0-9]|[1-5][0-9]|60
0
 

Author Comment

by:ourbhoy
ID: 20072064
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?
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20073025
Yes You correct. The | means simply OR, so there ae three patterns to mach
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension . This reminded me of questions that come up here at EE along the lines of, "How can I tell the type of file from its cont…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question