- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2014-03-20 10:41 编辑
回复 1# three_body
There are many way to do that ...
1. to get the data by two sections key word
service=NETBIOS (NS) proto=17
# awk 'function get(k,n, s,e,t){t=length(k)+1;s=index($0,k"=");e=index($0,n"=");if(s<e){return(substr($0,s+t, e-s-t-1))}return""}{print get("service", "proto")}' FILE
http
NETBIOS (NS)
VDO Live (tcp)
2. assign the each key and value to an array and use easily
service=NETBIOS (NS) proto=17
# awk -F= '{for(n=1;n<NF;n++){k=$n;v=$(n+1);sub(/.+ /,"",k);sub(/ [^ ]+$/,"",v);a[k]=v}print a["service"], a["ip"]}' FILE
http 119.188.11.3
NETBIOS (NS) 119.188.11.3
VDO Live (tcp) 119.188.11.3
|
|