Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


     egrep  -o  `echo $regex` file

example of file

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


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.