Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
    
I believe you missed a $ sign: echo $regex –  jippie Nov 15 '12 at 20:21

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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