Additions:
replace fsf with free software foundation
break fields into lines
print fields 2 4 6 on separate lines and separate with a blank line
$ awk '{print $2 ; print $4 ; print $6 ; print "" }'
Additions:
Additions:
n=split($4,params,"&")
xips=params[n]
n=split(xips,ips,"=")
client=ips[n]
n=split(client,ip,"+")
if (n) {client=ip[n]}
# gsub($3,client,$8)
# gsub($3,client,$13)
print $1,$2,client,$4,$5,$6
Deletions:
n=split($4,params,"&")
xips=params[n]
n=split(xips,ips,"=")
client=ips[n]
n=split(client,ip,"+")
if (n) {client=ip[n]}
print $1,$2,client,$4,$5,$6
Additions:
n=split($4,params,"&")
xips=params[n]
n=split(xips,ips,"=")
client=ips[n]
n=split(client,ip,"+")
if (n) {client=ip[n]}
print $1,$2,client,$4,$5,$6
IN
x y z a=1&b=2&c=6 u v w
x y z a=1&b=2&c=3+4+5 u v w
OUT
x y 6 a=1&b=2&c=6 u v
x y 5 a=1&b=2&c=3+4+5 u v
Deletions:
n=split($8,params,"&")
xips = params[n]
n=split(xips,ips,"=")
client=ips[n]
pos = match(client,/\+/)
if ( pos != 0 ) {
n=split(client,ip,"+")
client=ip[n]
}
print $1,$2,client,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15
Additions:
print $1,$2,client,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15
Deletions:
print $1,$2,client,$4 #,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15
Additions:
client=ips[n]
pos = match(client,/\+/)
if ( pos != 0 ) {
n=split(client,ip,"+")
client=ip[n]
}
print $1,$2,client,$4 #,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15
Deletions:
$ awk -f script aaa.log | head
print $1,$3,ips[2]
Additions:
awk script
$ awk -f script aaa.log | head
/^#/ {print}
!/^#/ {
n=split($8,params,"&")
xips = params[n]
n=split(xips,ips,"=")
print $1,$3,ips[2]
}
Additions:
Use awk to passthru comments, split uri (8th field) and print value of 21st parameter
10.10.10.10
10.10.10.10
Deletions:
87.103.41.223
87.103.41.223
87.103.41.223
Additions:
split a split
$ awk '/^#/ {print} !/^#/ { split($8,url,"&") ; split(url[21],ip,"=") ; print ip[2] }' aaa.log | head
#Remark: DCS-p
#Software:
WebTrends SmartSource Data Collector V8.0
#Version: 1.0
#Date: 2006-11-14 09:33:48
#Fields: date time c-ip cs-username cs-host cs-method cs-uri-stem cs-uri-query sc-status sc-bytes cs-version cs(User-Agent) cs(Cookie) cs(Referer) dcs-id
87.103.41.223
87.103.41.223
87.103.41.223
Additions:
passthrough
split
Use awk to pass thru # comment lines and print first middle part of domain name from 5th field
$ awk '/^#/ {print} !/^#/ { split($5,url,".") ; print $1,$3,url[2] }' aaa.log | head
Additions:
Use awk to pass thru # comment lines and print first three (space delimited) fields of a file
$ awk '/^#/ {print} !/^#/ {print $1,$2,$3}' aaa.log | head
Additions:
Deletions:
GNU awk
The oldest known version of this page was edited on
2006-11-16 08:55:56 by WikkaWiki (unregistered user)
GNU awk
reverse
Use awk to print first three (space delimited) fields of a file in reverse order
$ awk '{print $3,$2,$1}' aaa.log