Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

my target is to match snmpmanager string from /etc/hosts file in Solaris machine

I don’t get any match output from the following command (but snmpmanager already defined in host file) why??

 egrep -i '(^|[[:space:]])snmpmanager($|[[:space:]])'  /etc/hosts

my host file      loghost   Master SyslogSer vip Tcc NtpServer1 NtpServer2 snmpManager snmpManagerPA1 snmpManagerPA2

I also tried the following but without success -:(

   egrep -i '(^|[\s])snmpmanager($|\s])'  /etc/hosts
   egrep -i '(^|[\t])snmpmanager($|\t])'  /etc/hosts
share|improve this question

Unfortunately Solaris' regular expression parsing is limited at what it can do.

You can try doing:

egrep '(^| )snmpmanager($| )' /etc/hosts

But I would simply use PERL and \b tags.

share|improve this answer
I find the solution for solaris its - grep -iwc snmpManager (only need to add w flag) – Eytan Feb 8 '12 at 17:54
@eytan if your solution works, its good to have you make it an answer, and accept it, so the question is closed out – Rich Homolka Feb 8 '12 at 18:03

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.