#!/bin/bash
# Author: kingliyou
# Due Date 23/11/05
# Version 1.0
# Description: A simple script using 'sed' 'awk' 'grep' as filters
# to re-allocate the text files
echo 'IP Address Filter'
echo
echo "Please enter any key to continue"
finish=no
while [ $finish = "no" ]; do
echo
echo IP ADDRESS FILTER MENU
echo ======================
echo
echo "Enter For Options"
echo "------------------------"
echo " 1 Attemp Times"
echo " 2 Incoming IP Address List"
echo " 3 Sorted Address"
echo " Q Quit Log"
echo
echo "Please Select Option:"
read Option
cat mail.log | grep "rejected" > rejected
if [ $Option = "1" ]; then
echo This is a list of "rejected" mail attempt times:
echo
cat rejected | awk '{ print $5 }' | sed -e 's/sm-mta//g' | sed -e 's/://g' | sed -e 's/\[//g ' \
| sed '1, $s/]//g' | sort -b -nr | less
elif [ $Option = "2" ]; then
echo Incoming IP Address List:
echo
echo Press 'Y' to get the result:
echo
read ans
if [ "$ans" = "Y" -o "$ans" = "y" ]; then
cat rejected | awk -F "from" '{ print $2 }' | awk '{ print $1 }' | less
else
echo ' Permission Denied....... '
echo
fi
elif [ $Option = "3" ]; then
echo Press "Y" to get Sorting List:
echo
read ans
if [ "$ans" = "Y" -o "$ans" = "y" ]; then
cat rejected | awk -F "from" '{ print $2 }' | awk '{ print $1 }' | less > temp1
cat temp1 | sort | uniq -c | tr -d .
cat temp1 | sort | uniq -c | tr . ' ' > temp2
cat temp2 | awk '{ print $2, $3, $4, $5 }' > temp3
cat temp2 | awk '{ print $1 }' > temp5
cat temp3 | sort -k1n -k2n -k3n -k4n > temp4
cat temp4 | tr ' ' . > temp6
paste temp5 temp6 | less
else
echo ' IP Address is not sorted......... '
echo
echo ' Press any key to continue........ '
fi
elif [ $Option = "Q" -o $Option = "q" ]; then
finish=yes
else
echo "Invalid Choice. Try Again Please"
echo
fi
echo
echo Press 'Return' to QUIT
read dummy
done
|