1

On Linux machines I use this syntax, in order to match all VALID ip's.

My question: what needs to change for egrep command in order to run the egrep on Solaris?

According to egrep manual page "-o" isn't a legal option.

What is the alternative for Solaris?

     regex="(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"

     egrep  -o  `echo $regex` file

example of file

32)5.500.5.5*kjcdr
##@$1.1.1.1+++jmjh
1.1.1.1333
33331.1.1.1
@5.5.5.??????
~3de.ede5.5.5.5
1.1.1.13444r54
192.9.30.174
&&^#%5.5.5.5
:5.5.5.5@%%^^&*
:5.5.5.5:
**22.22.22.22
172.78.0.1()*5.4.3.277
  • I believe you missed a $ sign: echo $regex – jippie Nov 15 '12 at 20:21
3

On my Solaris systems, even the xpg4 version of grep does not include the -o option.

But if you have the SUNWggrp package installed, you'll find GNU egrep available as /usr/sfw/bin/gegrep.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.