[英]awk match multiple regular expression strings and digits from a line
我試圖匹配httpd日志文件中每行中的多個項目。 線條看起來像這樣:
192.168.0.1 - - [06/Apr/2016:16:35:42 +0100] "-" "100" "GET /breacher/gibborum.do?firstnumber=1238100121135&simple=1238100121135&protocol=http&_super=telco1 HTTP/1.1" 200 161 "-" "NING/1.0"
192.168.0.1 - - [06/Apr/2016:16:35:44 +0100] "-" "00" "GET /breacher/gibborum.do?firstnumber=1237037630256&simple=1237037630256&protocol=http&_super=telco1 HTTP/1.1" 200 136 "-" "NING/1.0"
192.168.0.1 - - [06/Apr/2016:16:35:44 +0100] "-" "00" "GET /breacher/gibborum.do?firstnumber=1238064400578&simple=1238064400578&protocol=http&_super=telco1 HTTP/1.1" 200 136 "-" "NING/1.0"
我試圖提取_super變量的數字,時間戳和值。 到目前為止,我可以用這個提取數字和時間戳:
awk '{match ($0, /123([0-9]+)/, arr); print $4, arr[0]}'
請問如何在_super =變量的末尾提取值?
您可以像這樣更改腳本:(添加gsub
和$9
):
awk '{match ($0, /123([0-9]+)/, arr); gsub(/.*_super=/, "",$9); print $4, arr[0], $9}'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.