Quickie sed and awk to slice up Apache logs

This comes in very handy.

To get a log slice from a given date to the end:

# sed -n '/15\/Nov\/2010/,$ p' /path/to/access_log

Or, get a log slice in a given date range:

# sed -n '/5\/Nov\/2010/,/5\/Dec\/2010/ p' /path/to/access_log

Do something like this to filter and sort the results:

# awk '{print $2,$6}' access_log | sort -fr

Leave a comment

Your email address will not be published. Required fields are marked *