Coloured logs
From AssaultWiki
#!/bin/sh
#
# CatCuBeLog
# by MeatROme - historically interesting, done by engine-code nowadays ;)
C_="\033[m"
# 0 : green, 1 : blue, 2 : yellow, 3 : red, 4 : gray, >=5 : white
# 0 : 32 1 : 34 2 : 33 3 : 31 4 : 37 5 : 1
C0=32
C1=36
C2=33
C3=31
# post gui-release| sed s/^/"$C5"/g
C4="1\;30"
C5="1\;37"
S0=""
if [ "$1" != "-" ]
then
S0="$(cat "${1}" | sed 's/^/\\033[40m\\033[1;37m\ /g')"
else
S0="$(cat /dev/stdin | sed 's/^/\\033[40m\\033[1;37m\ /g')"
fi
S1=$S0
CX=0
for cc in $C0 $C1 $C2 $C3 $C4 $C5; do
S1=$(echo "$S1" | sed s/^${CX}/\\\\033[${cc}m/g)
CX=$(echo 1+$CX|bc)
done
# eliminate other colour-chars quietly
S2=$(echo "$S1" | sed 's/^./\\033[1;37m/g')
S1="$S2"
# eliminate dangling colour setting
S3=$(echo "$S1" | sed 's/$/\\033[m/g')
S1="$S3"
if [ -n "$2" ]
then
case "$2" in
"-s")
echo "$(echo "$S1$C_" | awk -f /usr/local/bin/.awk/history.awk | sort -n | sed 's/\ /\\033[1;37m\t\t/2' | sed 's/^/\ \\033[1;34m/g')"
;;
"-u")
echo "$S1$C_" | sort | uniq -c | egrep -v "^\ +1\ "
;;
*)
echo "$S1$C_"
;;
esac
else
echo "$S1$C_"
fi
This makes use of the following awk-file .. which I don't remember where I found it originally. If you don't change the location in the source above, place this into /usr/local/bin/.awk/history.awk
# histsort.awk --- compact a shell history file
# Thanks to Byron Rakitzis for the general idea
{
if (data[$0]++ == 0)
lines[++count] = $0
}
END {
for (i = 1; i <= count; i++)
print data[lines[i]], lines[i]
#print lines[i]
}
Back to server hints 1.0.4.