Results 1 to 4 of 4
Hi, this is my first post as I'm just starting to learn about grep and all it's powers since my company purchased Linux based software for our proxy server.
Anyways, ...
- 01-04-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 2
Script parse Squid logs
Hi, this is my first post as I'm just starting to learn about grep and all it's powers since my company purchased Linux based software for our proxy server.
Anyways, I'm trying to write a script that I can use to parse the squid logs.
The logs look like this:
It would be great if I could have a way to enter a cetain date and ip and parse that out into a file.Code:2007.12.30 4:24:26 - xx.xx.xx.xx http://url.url.com/ 2008.1.3 8:42:15 - xx.xx.xx.xx http://url.url.com/
Right now I only know how to get the lines matching an IP, but I'd like to match an IP and Date. The time is irrelevant to me.
Thats what I'm doing now. How can I improve on this or even have a script that I can update the IP and Date I want and have it create a new log file naming it the current date.Code:grep 'xx\.xx\.xx\.xx' file >> todaysdate.log
Thanks in advance for any help.
- 01-06-2008 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
If awk is allowed:
Usage: <scriptname> <date> <IP>Code:#!/bin/sh awk -v date="$1" -v ip="$2" ' $1 == date && $2 == ip {print} ' logfile > todaysdate.log
Regards
- 01-06-2008 #3Just Joined!
- Join Date
- Jan 2008
- Posts
- 2
Thanks
Hey fantastic! Thanks a bunch, it'll be a big help.
One thing I had hoped, is there a way to add into that, instead of always naming the output the same thing, to have it auto create the filename to the days actual current date?
- 01-06-2008 #4


Reply With Quote