epita-std
/
ACU
Archived
1
0
Fork 0
This repository has been archived on 2021-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
ACU/process/view_log.sh

75 lines
1.1 KiB
Bash
Executable File

#! /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