[root@ Statistic]# cat Statistic.sh
#!/bin/bash
Date=$(date -d "+1 day ago" +%F )
Path=/app/logs/
echo $Date
echo "=============================================="
echo "login user info"
echo "Frequency UserName"
grep userName ${Path}catalina.out | grep `date -d "+1 day ago" +%m-%d` |awk -F ": " ‘{print $2}‘ | awk -F "]" ‘{print $1}‘ | awk -F "userName=" ‘{print $2}‘ | awk -F [ ‘{print $2}‘ |sort |uniq -c |sort -nr -k 1
#echo "Frequency UserName "
#grep userName /logs/app.log.2016-`date -d "+1 day ago" +%m-%d` |awk -F userName= ‘{print $2}‘ | awk -F ] ‘{print $1}‘ | awk -F [ ‘{print $2}‘ |sort |uniq -c |sort -nr -k 1
echo "=============================================="
echo " "
echo "PV"
grep "GET / HTTP" ${Path}localhost_access_log.${Date}.txt |wc -l
echo "=============================================="
echo " "
echo "UV"
grep "GET / HTTP" ${Path}localhost_access_log.${Date}.txt | awk ‘{print $1}‘ | sort |uniq -c | wc -l
echo "=============================================="
echo " "
echo "IP "
awk ‘{print $1}‘ ${Path}localhost_access_log.${Date}.txt |sort |uniq -c | wc -l
原文地址:http://wangqh.blog.51cto.com/5367393/1794176