-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb_count.sh
More file actions
46 lines (39 loc) · 1.13 KB
/
Copy pathweb_count.sh
File metadata and controls
46 lines (39 loc) · 1.13 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
#web_count.sh
if [ $# -eq 0 ];then
echo "Error : please specify logfile."
exit 0
else
LOG = $1
fi
if [ ! -f $1 ];then
echo "Sorry,sir, I can't find this log file, please check and try again!"
exit 0
fi
echo "Most of the ip:"
echo "----------------------------------------------------"
awk '{print $1}' $LOG |sort |uniq -c|sort -nr|head -10
echo
echo
echo "Most of the time:"
echo "----------------------------------------------------"
awk '{print $4}' $LOG |cut -c 14-18 |sort |uniq -c|sort -nr |head -10
echo
echo
echo "Most of the page:"
echo "----------------------------------------------------"
awk '{print $11}' $LOG |sed 's|^.*\(.cn* \)\"|\1|g'|sort |uniq -c |sort -rn |head -10
echo
echo
echo "Most of the time / Most of the ip:"
echo "----------------------------------------------------"
awk '{print $4}' $LOG |cut -c 14-18 |sort -n |uniq -c |sort -nr |head -10 > timelog
for i in `awk '{print $2}' timelog `
do
num = `grep $i timelog |awk '{print $1}'` //number of every time
echo "$i $num"
ip= `grep $i $LOG |awk '{print $1}' |sort -n | uniq -c |sort -nr |head -10`
echo "$ip"
echo
done
rm -f timelog