駕駛自己的堅果。我試圖從access.log中取得域名(http://www.example.com)。什麼日誌是這樣的:刪除一切後模式(.com)
tail access.log
Fri, 13 Jul 2012 20:32:03 -0700,INFO,6fgmd8fk,params,http://www.example.com/images/CIV-260.jpg|
我已經試過(with sed and awk)這一個班輪的許多變化:
tail -4 access.log |grep http |awk {'print $6'} |cut -c28- |awk '$1>".com"' |sort |uniq
http://www.example.com/2713-7807.jpg|
http://www.example.com/2713-7808.jpg|
http://barfoo.com/img/14616_20120711182527.jpg|
http://foobar.com/css/14616_20120713142151.css|
我卡住了。
這個作品很好。非常感謝。 – jdorfman 2012-07-14 06:36:56
這實際上解決了很多更好的謝謝! https://gist.github.com/3109778 – jdorfman 2012-07-14 07:01:47
@jdorfman:只是一個簡單的參考,您可以使用'tac'來反轉流而不是'sort -nr'。 – Thor 2012-07-14 08:10:24