Regular expression help

Hi list,

I need help in putting a regular expression, regular expression should
find either of these four words:

shut reb sync init

I am trying to find either shutdown or reboot or sync or init, for Linux
it works fine if I put crontab -l |grep -iP “(shut|init|sync|reb)” but
in Solaris it is failing because it doesn’t have regular expression
option which is -P.

So I am trying to make this through regular expression.

Thanks in advance

Try crontab -l |egrep -i “(shut|init|sync|reb)”

----- Original Message -----
From: “Rajesh M.” [email protected]
To: “ruby-talk ML” [email protected]
Sent: Friday, December 10, 2010 7:58:35 PM
Subject: Regular expression help

Hi list,

I need help in putting a regular expression, regular expression should
find either of these four words:

shut reb sync init

I am trying to find either shutdown or reboot or sync or init, for Linux
it works fine if I put crontab -l |grep -iP “(shut|init|sync|reb)” but
in Solaris it is failing because it doesn’t have regular expression
option which is -P.

So I am trying to make this through regular expression.

Thanks in advance

On Fri, Dec 10, 2010 at 9:58 PM, Rajesh M. [email protected] wrote:

option which is -P.

How about

crontab -l | grep -i -e shut -e init -e sync -e reb

On 11.12.2010 07:06, Josh C. wrote:

I am trying to find either shutdown or reboot or sync or init, for Linux
it works fine if I put crontab -l |grep -iP “(shut|init|sync|reb)” but
in Solaris it is failing because it doesn’t have regular expression
option which is -P.

What do you need -P for? There is no specific perlism in the regexp.
Instead you can use egrep to make “|” meta. Note also that you do not
need brackets.

So I am trying to make this through regular expression.

How about

crontab -l | grep -i -e shut -e init -e sync -e reb

Or

crontab -l | egrep -i “shut|init|sync|reb”

Note: you may have to use a specific egrep for it to understand -i -
Solaris is such a mess in this regard.

Cheers

robert

How about
crontab -l | grep -i -e shut -e init -e sync

-e isn’t a grep option on Solaris. [-bhinsvwx]

Either of these should work:

egrep -i “(shut|init|sync|reb)”
/usr/xpg4/bin/grep -i -E “(shut|init|sync|reb)”