Sorting Apache Log Files

by @jehiah on 2004-11-22 11:34UTC
Filed under: All , Articles

Needed a way to sort an apache log file recently after combining multiple log files and the records were no longer ordered by date. This is the script I came up with, but I can’t remember where I got it from.

#!/bin/sh
if [ ! -f $1 ]; then
    echo "Usage: $0 "
    exit
fi
echo "Sorting $1"
sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M -k 4.2,4.3n -k 4.14,4.15n -k 4.17,4.18n -k 4.20,4.21n $1 > $2
Subscribe via RSS ı Email
Jehiah Czebotar