I really need your help to make a script to split a large squid's log file into a multiple files, each of them containing the log entries for every logged date.
To achieve the result I planned to use the function "date" with the first log field as a parameter using this syntax:
date -d @(ten number squid timestamp field) +%F
to obtain the desired filename for splitted logs.
Example:
# date -d @1232163496 +%F
will return: 2009-01-16
The idea is to analize the first field of each line in the log file and append whole line to the corresponding file.
The first field of the log is the date and time in UNIX format (seconds since 1/1/1970). Analizing this field (as proposed in my first post), two dates as registered: jan 25 2009 and jan 26 2009, thus two files must be generated:
2009-01-25 containing:
1232935790.356 1795 192.168.0.10 TCP_MISS/200 551 GET http://www.cubachat ...
1232935790.383 1645 192.168.0.55 TCP_MISS/302 619 GET http://images.imagef ...
1232935791.271 888 192.168.0.55 TCP_MISS/302 618 GET http://images.imagef ...
1232935796.064 1444 192.168.0.55 TCP_MISS/302 619 GET http://images.imagef ...
1232935797.477 1412 192.168.0.55 TCP_MISS/302 618 GET http://images.imagef ...