Very good, that works!
Could you define a "globbing pattern"? Is it the ksh equivalent of a
regexp?
Interestingly, I have another regular expression in my script, and this
seems to work fine:
*[!0-9]*
As I say, I am new to ksh!
Stephane Chazelas wrote:
> On 17 Aug 2006 01:55:11 -0700, Kev wrote:
> > Hi,
> >
> > In a ks script I have written, the first arg is an IP address - I
> > decided to check the validity of this using a regular expression:
> >
> > #Check validity of arg1
> > if [[ "$1" =
> > \b(?
?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b
> > ]]
> > then
> > echo "Arg1 is a valid IP address"
> > else
> > echo "Arg1 is invalid"
> > fi
> >
> > The regex may not be the most effiecient, but it is right, anyway, when
> > I run the script, I get:
> >
> > ./scriptabc.ksh: syntax error at line 17 : `(' unexpected
> >
> > What am I doing wrong? (I am relatively new to ksh)
> [...]
>
> You're using a perl regular expression where ksh is expecting a
> ksh globbing pattern.
>
> try:
>
> if perl -e 'exit(1) unless shift(@ARGV) =~ /your-regexp/' "$1"
> then
> ...
>
>
> instead
>
>
> --
> Stephane