LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2009, 09:41 PM   #1
mlapl1
LQ Newbie
 
Registered: Jun 2007
Posts: 16

Rep: Reputation: 0
Identifying - sorting referring IP/Domain in access_log


Hello

I need a bit of help

I have a log file: access_log

Like all log files, it looks like this:

66.249.65.78 - - [07/Aug/2009:07:05:33 +1000] "GET /e107_plugins/calendar_menu/event.php?1879250400 HTTP/1.1" 200 25168 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

24.181.70.120 - - [07/Aug/2009:07:24:10 +1000] "GET /index.php HTTP/1.1" 200 39367 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"

216.129.119.10 - - [07/Aug/2009:12:35:37 +1000] "GET /robots.txt HTTP/1.0" 200 523 "-" "Mozilla/5.0 (Twiceler-0.9 http://www.cuil.com/twiceler/robot.html)"


Each line is preceded by a referring IP address (see above in red).

I would like to go through my logfile and list ONLY the referring address.

Also, I would like to see that address only ONCE.

This would give me a list of all addresses listed only once - I could then go through and inspect that list.

How do I go about doing this in a simple way. I have tried various combinations of uniq and cut and sort to no avail. I guess I could try to write an awk/gawk/perl script but time is flying away.

I would really appreciate some help.
Thank you
Andrew
 
Old 08-06-2009, 11:21 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
Code:
cat file | cut -d' ' -f1 |sort -u
 
Old 08-07-2009, 05:47 AM   #3
mlapl1
LQ Newbie
 
Registered: Jun 2007
Posts: 16

Original Poster
Rep: Reputation: 0
Thank you very much Chris - cheers - Andrew
 
  


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
dropline gnome-terminal error: couldnt get a file descriptor referring to the console Randux Slackware 5 12-05-2006 01:55 PM
Referring to current file/path in vim's :!<cmd> jrdioko Linux - Software 1 01-27-2006 04:03 PM
Question about referring a word in a command output aaronshi *BSD 2 05-14-2005 10:47 PM
bash scripting - referring to external arguments into loops linsson Linux - General 2 07-23-2004 12:24 PM
is there a way not to type LD_LIBRARY_PATH referring to the *.so everytime you log on captainstorm Programming 4 07-01-2003 01:47 AM


All times are GMT -5. The time now is 02:57 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration