Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Narrowing down an IP address match

Status
Not open for further replies.

forrie

MIS
Mar 6, 2009
91
US
This was discussed in:

thread822-1189907

I'm using FreeBSD-7.1-STABLE. I can't get grep to use boundaries like \< and \>.

I have a file, /etc/mail/access, that has IP addresses followed by tab, and configuration information. The format is like this:

11.22.33 SOME CONFIG DIRECTIVE

Now, what I'm trying to do is grep for a specific IP address, not similarities.

For example, grep will pick up:

11.22.33
11.22.3

From what I read, I should be able to do something simple like this:

grep '\<11\.22\.3\>' /etc/mail/access

or some variation thereof, and it does not work.

I'm really puzzled by this one. fgrep and it's relatives don't return the expected result, either.

Can someone point out what I'm missing here.

Thanks.

 
What about this ?
Code:
awk '$1=="11.22.3"' /etc/mail/access

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I should have been more specific. I have a script that, when passed a variable (which is an IP address), it takes the first 3 octets into a variable -- I expect(ed) grep to return a 0 (false) or 1 (true) if it exists in the file; if it doesn't, put it there.


Thanks.
 
I figured it out. The reference material I used wasn't very complete.

grep "11.22.33/>" filename

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top