#!/bin/sh
file='admin.log';
file1='/tmp/temp';
file2='/tmp/temp1';
a=0;
b=1;
parser () {
cat $file | awk '{ print $2 }' | grep -v SIGCHLD | grep -v LARGEFILE | grep -v unfinished | grep -v 0x | sed -e 's/"//g' -e 's/,//g' -e 's/\\177//g' -e 's/\=//g' -e 's/\\10//g' -e 's/\\7//g' -e 's/[\33\[A]//g' -e 's/\[//g' -e 's/\\33//g' -e 's/B//g' > $file1
cat /dev/null > file;
count=$(wc -l $file1 | awk '{ print $1 }');
for i in `seq 1 $count`; do
a=$(($a + $b));
name=`cat $file1 | head -n $a | tail -n 1 | head -n 1`;
#echo $name;
#echo $name;
array[$i]="$name";
if [ "${array[$i]}" == "" ]; then
#echo "empty space";
echo -n -e " " >> $file2;
echo -n -e " ";
elif [ "${array[$i]}" == "\\r" ]; then
#echo "Newline";
echo -e "\r" >> $file2;
echo -e "\r";
elif [ "${array[$i]}" == "\\t" ]; then
echo -e -n "\t" >> $file2;
echo -e -n " ...";
echo -e "\t";
elif [ "${array[$i]}" == "\\n" ]; then
echo -e "\n" >> $file2
echo -e "\n";
elif [ "${array[$i]}" == "SIGINT" ]; then
echo " ^C"; 
echo " ^C" >> $file2;
#elif [ "${array[$i]}" == "\33" ]; then
#echo " UP or DOWN Key Pressed";
#echo " UP or DOWN Key Pressed" >> $file2;
elif [ "${array[$i]}" == "[A" ]; then
echo -n;
else
echo -n "${array[$i]}" >> $file2;
echo -n "${array[$i]}";
fi
done
}

parser;
