-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathipLogParser.sh
More file actions
32 lines (30 loc) · 836 Bytes
/
Copy pathipLogParser.sh
File metadata and controls
32 lines (30 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#***************************************************
# $ ./ipLogParser.sh <path> <ip>
#***************************************************
i=0
patron=$2
typeset ARRAY[10]
for file in $(find $1 -type "f")
do
i=$(($i+1));
l=0
while read line
do
pos=$(($l%10));
ARRAY[$pos]=$line
case $line in
*"$patron"*)
posip=$(($l-8));
pos=$(($posip % 10));
ip=${ARRAY[$pos]}
#Next, you can indicate an IP addresses to ignore
if [[ $ip != *"8.8.8.8"* ]]
then
echo -e "**********************\nFile: $file\nLine: $l\nIP: $ip\nLog: $line\n**********************\n";
fi
esac
l=$(($l+1));
done < "$file"
done
echo "Files analyzed: $i";