LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-08-2006, 10:37 AM   #1
wwnexc
Member
 
Registered: Sep 2005
Location: California
Distribution: Slackware & Debian
Posts: 264

Rep: Reputation: 30
Arrow Filter Search Results


Hi,

I have been running a little server for a while, and i am wondering how many people have used it. The server creates crappy logfiles.

I am trying to find the command which would allow me to print only the matching characters per line in the input file and follw each result with a line break.

The results therefore should look something like this (a list of all ip addresses from a bunch of crappy logfiles):
Code:
64.1.2.3
126.89.42.22
5.23.95.45
...
and so on.

I was thinking about a program which matches something like this:
Code:
[:digit:]\{1,3\}\.[:digit:]\{1,3\}\.[:digit:]\{1,3\}\.[:digit:]\{1,3\}
(I hope the above regular expression is correct. It should match all numbers in the following pattern nnn.nnn.nnn.nnn

The program is only supposed to print matches of the expression, not the entire line of its context.

THANKS!!

Last edited by wwnexc; 05-08-2006 at 10:41 AM.
 
Old 05-08-2006, 11:06 AM   #2
frankjoshua
Member
 
Registered: May 2006
Posts: 32

Rep: Reputation: 15
Try this:
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /var/log/mylog.log
or
dmesg | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'

you must have the slashes and single quotes.

Last edited by frankjoshua; 05-08-2006 at 11:09 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do list the results from my search form? Alexander.s Programming 4 05-09-2005 11:01 AM
Search results page header lhoff LQ Suggestions & Feedback 4 09-14-2004 09:09 AM
The new Search Results page is not as good as the old one ? qwijibow General 2 07-25-2004 03:31 PM
search within results toastermaker LQ Suggestions & Feedback 1 11-20-2003 01:11 AM
Apollon: no search results m00nd0g Linux - Software 1 07-26-2003 05:06 PM


All times are GMT -5. The time now is 09:16 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration