SHARE
TWEET

Untitled

a guest Jan 6th, 2012 588 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   #!/bin/bash
  2.   if ls ./*.result &> /dev/null #判断当前目录中是否有后缀名为result的文件存在
  3.   then
  4.     rm *.result #如果有的话,删除这些文件
  5.   fi
  6.   touch log.result #创建一个空文件
  7.   for i in www-*.log #遍历当前目录中所有log文件
  8.   do
  9.     echo $i ... #输出一行字,表示开始处理当前文件
  10.     awk '$9 == 200 {print $7}' $i|grep -i '^/blog/2011/.*\.html$'|sort|uniq -c|sed 's/^ *//g' > $i.result #生成当前日志的处理结果
  11.     cat $i.result >> log.result #将处理结果追加到log.result文件
  12.     echo $i.result finished #输出一行字,表示结束处理当前文件
  13.   done
  14.   echo final.log.result ... #输出一行字,表示最终统计开始
  15.   sort -k2 log.result | uniq -f1 --all-repeated=separate |./log.awk |sort -rn > final.log.result #生成最终的结果文件final.log.result
  16.   echo final.log.result finished #输出一行字,表示最终统计结束
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top