Regular expression help

R

Rajesh M.

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
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

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
How about

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

Robert Klemme

[Note: parts of this message were removed to make it a legal post.]

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.

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.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,836
Messages
2,569,748
Members
45,545
Latest member
rapter____0

Latest Threads

Top