#! /bin/sh cd `dirname $0`/.. UN=$1 if [ "$1" = "clean" ] then CMD=rm shift elif [ "$1" = "full" ] then CMD=cat shift elif echo "$1" | grep -e '^-' > /dev/null then CMD="tail -n `echo $1 | cut -d '-' -f 2-`" shift else CMD="tail -n 50" fi DIRS="./" if [ -d "/var/log/hooks/" ] then DIRS="$DIRS /var/log/hooks/" fi if [ $# -eq 0 ] then for D in $DIRS do for I in `find "$D" -name '*.log'` do /bin/echo -e "`dirname ${I#$D}`/\e[1m`basename $I`\e[0m" done done else if [ `uname -s` = "FreeBSD" ] then LIST=`mktemp lerdorf_log_XXXXX` else LIST=`mktemp` fi find $DIRS -name '*.log' > "$LIST" while [ $# -gt 0 ] do NB=`grep "/$1" "$LIST" | wc -l` if [ $NB = 1 ] then $CMD `grep "/$1" "$LIST"` echo elif [ $NB -gt 1 ] then echo "Too much matching file for '$1':" for I in `grep "$1" "$LIST" | sed -E 's#^./##'` do /bin/echo -e "`dirname $I`/\e[1m`basename $I`\e[0m" done else echo "Unable to find '$1' log file" exit 1 fi shift done rm -rf "$LIST"; fi