The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep ip address rein Shell Programming and Scripting 2 05-22-2009 01:25 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-05-2007 02:59 AM
How to grep dhcp ip address chongkls77 Shell Programming and Scripting 4 03-28-2007 09:27 AM
How to Achive IP address through MAC(Ethernet) address krishnacins IP Networking 3 08-29-2005 08:45 PM
network address and broadcast address? pnxi UNIX for Dummies Questions & Answers 7 11-10-2003 11:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-03-2008
wfleenor wfleenor is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1
Grep Ip address

I'm looking a Grep or egrep statement that would allow me to exclude the a range of ip address via the last octet
example egrep -v "*.*.*.(54|61)" from a syslog file.... would this work?
  #2 (permalink)  
Old 03-05-2008
grumpf grumpf is offline
Registered User
  
 

Join Date: May 2006
Posts: 101
and ip address is something like 255.255.255.255. and you what an RE for that ?

[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ you may like to fine tune it a bit
  #3 (permalink)  
Old 03-05-2008
earnstaf earnstaf is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
Quote:
Originally Posted by wfleenor View Post
I'm looking a Grep or egrep statement that would allow me to exclude the a range of ip address via the last octet
example egrep -v "*.*.*.(54|61)" from a syslog file.... would this work?
Maybe something like:
Code:
egrep -v "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[^54-61]" file
Not positive if that last part of the regexp works...
  #4 (permalink)  
Old 03-06-2009
forrie forrie is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 2
Searching for instance of specific IP in a file

I have a similar question, so I'll post it here.

I have a script that blocks IPs, but checks first to see if the given IP exists in a file before proceeding. In one case, it's /etc/mail/access (Sendmail). The format is generally:

11.22.33 REJECT or SOME MESSAGE

Now, say I log an IP of 11.22.3, when I egrep for it, it will also match 11.22.33, which I don't want.

So I'm trying to figure out how to limit the egrep search for only that IP - establishing a boundary on the search, which I'm not able to figure out.


thanks.

Last edited by forrie; 03-06-2009 at 12:23 PM.. Reason: typo
  #5 (permalink)  
Old 03-07-2009
earnstaf earnstaf is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
Quote:
Originally Posted by forrie View Post
I have a similar question, so I'll post it here.

I have a script that blocks IPs, but checks first to see if the given IP exists in a file before proceeding. In one case, it's /etc/mail/access (Sendmail). The format is generally:

11.22.33 REJECT or SOME MESSAGE

Now, say I log an IP of 11.22.3, when I egrep for it, it will also match 11.22.33, which I don't want.

So I'm trying to figure out how to limit the egrep search for only that IP - establishing a boundary on the search, which I'm not able to figure out.


thanks.
Put a space after the last number?
Code:
egrep "11.22.3 " file
  #6 (permalink)  
Old 03-07-2009
forrie forrie is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 2
That doesn't work, as the next character is a TAB --

I'm still puzzled why the metacharacters \< and \> don't work for bounaries, too.

Thanks.
  #7 (permalink)  
Old 03-07-2009
ldapswandog ldapswandog is offline
Registered User
  
 

Join Date: Feb 2009
Location: Charlotte, NC
Posts: 101
grep "11.22.3\>" file will work, you may have left out the quotes
Closed Thread

Bookmarks

Tags
grep or

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0