#!/bin/bash if [[ "$1" = "" ]];then apachelog more; else site=$1; shift; if [[ "$1" == "" ]];then t=$site; site=""; path="/var/log/apache2/error.log"; else t=$1; shift; path="/var/log/apache2/$site.error.log"; fi; case "$t" in search) cat $path | grep "$@"; ;; ignore) cat $path | grep -v "$@"; ;; tail) if [[ "$@" == "" ]];then tail -f $path; else tail --lines="$@" $path; fi; ;; more) more $path; ;; flush) echo "" > $path; ;; sites) ls /var/log/apache2/*.error.log | awk '{print gensub(/\.error\.log$/, "", "g", gensub(/^.*\//, "","g"))}'; ;; *) echo "Usage: $0 [{search|ignore|tail|more|flush|sites} ]"; exit 1; esac; fi;