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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Match 1-6 in /bin/sh. 1

Status
Not open for further replies.

AnotherAlan

Technical User
Feb 10, 2006
362
GB
Hi all,

Sorry about this, it's probably an easy one.

In ksh I can match any character between 1 and 6 in an if statement like this;

if [[ "$1" = ukexmb0[1-6] ]]; then blah,

I can't work out how to do it in /bin/sh.

I've read the man page and it suggests to use ? as wildcard to match anything. I've also seen threads on this forum that use [x-x] quite happily.

I've tried so many combinations now that I can't even remember what I have done.

Please help, its Friday and I want to get to the pub.

Thanks
 
I've read the man page
In the sh man page have a look at case

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OK thanks PHV.

I'm back from the pub after sinking a couple of pints of London Pride so I may not fully understand your reply.

A case statement is not exactly what I'm looking for.
I could do this in ksh.
The logic is to send an email if the script encounters a particular string that matches a server name.
As there are only six possible outcomes I thought it would be possible to do this with wildcards.

Thanks
 
case $1 in ukexmb0[1-6]) : blah;; esac

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Ah, now I understand.

Thanks very much PHV.

Merci beaucoup.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top