squid日志转换


有squid日志如下,时间格式为时间戳形式(第一列),想把时间戳转化成日期时间的形式,求简单方法。

   
  1345184908.747      0 123.150.162.10 TCP_IMS_HIT/304 303 GET http://file.abcd.com/images/channel/content/images/share_mail/share_sina.gif - NONE/- image/gif
  
1345184908.749 43 58.216.147.234 TCP_MEM_HIT/200 28055 GET http://abcdimg.adsame.com/dolphinfile/abcd/2012/07/0_99.gif - NONE/- image/gif
1345184908.754 5 115.192.193.227 TCP_MEM_HIT/200 3210 GET http://file.abcd.com/file/vip/images/share_sina.png - NONE/- image/png
1345184908.757 2 1.24.206.18 TCP_IMS_HIT/304 303 GET http://file.abcd.com/images/channel/content/images/share_mail/share_163.gif - NONE/- image/gif
1345184908.760 0 211.140.5.115 TCP_MEM_HIT/200 7468 GET http://photos.abcd.com/2012-08-16/100424784_1.html? - NONE/- text/html
1345184908.767 0 183.28.87.191 TCP_MEM_HIT/200 7422 GET http://photos.abcd.com/2012-08-13/100423493_2.html - NONE/- text/html
1345184908.768 1 210.75.18.56 TCP_REFRESH_MISS/302 686 GET http://finance.abcd.com/2011-09-17/100303644.html - DIRECT/219.232.244.236 text/html
1345184908.769 0 106.80.185.210 TCP_MEM_HIT/200 874 GET http://file.abcd.com/file/homepage/images/new/bg_lm_bottom.gif - NONE/- image/gif
1345184908.770 0 1.24.206.18 TCP_IMS_HIT/304 303 GET http://file.abcd.com/images/channel/content/images/share_mail/share_douban.gif - NONE/- image/gif
1345184908.783 0 1.24.206.18 TCP_IMS_HIT/304 303 GET http://file.abcd.com/images/channel/content/images/share_mail/share_xianguo.gif - NONE/- image/gif

squid shell

自由D代价 12 years, 4 months ago
   
  perl -pe 's/^([\d.]+)/localtime($1)/e'  a.log > b.log
 

艾丽麦克道尔 answered 12 years, 4 months ago

Your Answer