Sort merged apache log-file by date

#!/bin/bash
if [[ $2 == "" || $1 == "" ]] || [ ! -f $1 ]; then
    echo "Usage: $0 input-file output-file"
    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

Reference: http://stackoverflow.com/questions/5672733/how-can-i-sort-an-apache-log-file-by-date

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>