- Problem:
- You create a large apache log file for the quarter by concatenating weekly
apache logs together, and you want to make sure that all of the logs
made it in sequence.
- Solution:
- Match the date header in each apache log entry, and print out the date
if it is different from the date on the last line. The correctly
formatted log will result in output that is in proper sequence. If you
want to get more sophisticated, you could use something like Date::Calc
and logically compare the dates in the program itself.
Sample line:
foo.example.com - - [11/Apr/2004:12:52:26 -0700] "GET /fujitsu/screenshot1_s.jpg HTTP/1.1" 200 37946 "http://www.greenfly.org/fujitsu/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040327 Firefox/0.8"
Parser:
[]$ cat Audit_2003_Qtr_1_full_log \
| perl -ne 'm|\[(\d+/\w{3}/\d+)|;
print "\n" if( ne $last);
$last = ;'