Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

 10.170.10.5      loghost
 10.170.10.61   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

1 Answer 1

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
1  
@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

 
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.