Sunday, December 22, 2013

Simple apache error code and reverse quantity sort[bash]

#!/bin/bash
#Author: Oh Young(Jooung). ohyoungjooung@gmail.com
# Simple apache error code and reverse quantity sort
temp=/tmp/sort_apache
echo "CODE,Quanty:"

five=`grep 502 apache_log | wc -l`
echo "502   $five" > $temp
four=`grep 400 apache_log | wc -l`
echo "400   $four" >> $temp
two=`grep 200 apache_log | wc -l`
echo "200   $two" >> $temp

cat $temp |  sort -k2 -rn

#cleaning /tmp/sort_apache
rm -f $temp