Hello,
I want to rewrite some logs from Apache with awk. For the moment I may filter only the lines I want but now in the selected lines, I want to rewrite only some informations from one of the fields.
Do you have an idea or hints to resolve my problem?
Thanks,
Denis
Example of my data:
192.1.201.100 - - [09/Jan/2004:12:01:05 +0100] "GET /directory1/Pagename1;jsessionid=00JSN0M5XEY+uo?productId=41104&E_mp=2101001000002-12&strAddress=&strLocation=montmirail&strCP=&strCountry=EUR HTTP/1.1" 200 8856
192.1.201.100 - - [09/Jan/2004:12:00:41 +0100] "GET /directory2/pagename2;jsessionid=0000GH320M5XEY+uo HTTP/1.1" 200 15616
192.1.201.100 - - [09/Jan/2004:12:01:10 +0100] "GET /directory2/pagename2;jsessionid=0000GJSN0M5XEY+upouo?from=0&rnd=10736400&E_mp=2105040103fra541104130x1103EUR000ebW9udG1p0002-12&stat=ambiguous_tourism&strChoice=0 HTTP/1.1" 200 34638
192.1.201.100 - - [09/Jan/2004:11:59:20 +0100] "GET /directory1/pagename2;jsessionid=0000LILFAAGRJGG1SWYNGKQUYZI+upoplruo?&E_mp=210504cGFyaXM000edHJhaW4gYmxldQ12091172.352671212&strLocation=Paris&stat=ambiguous_tourism&strCountry=1424&strAddress=&strCP=75000&productId=41102 HTTP/1.1" 200 16066
For this example, I want to write field 1 to 6,
for the field 7, only the part before ";jsessionid=..." and for the parameters (and values) after "?" only "&stat=value" and "&productId=value"
and all the fields after the field 7 (it's possible that the number af fields change between the differents lines)
The result for my example should be :
192.1.201.100 - - [09/Jan/2004:12:01:05 +0100] "GET /directory1/Pagename1?productId=41104 HTTP/1.1" 200 8856
192.1.201.100 - - [09/Jan/2004:12:00:41 +0100] "GET /directory2/pagename2 HTTP/1.1" 200 15616
192.1.201.100 - - [09/Jan/2004:12:01:10 +0100] "GET /directory2/pagename2?stat=ambiguous_tourism HTTP/1.1" 200 34638
192.1.201.100 - - [09/Jan/2004:11:59:20 +0100] "GET /directory1/pagename2?stat=ambiguous_tourism&productId=41102 HTTP/1.1" 200 16066
I want to rewrite some logs from Apache with awk. For the moment I may filter only the lines I want but now in the selected lines, I want to rewrite only some informations from one of the fields.
Do you have an idea or hints to resolve my problem?
Thanks,
Denis
Example of my data:
192.1.201.100 - - [09/Jan/2004:12:01:05 +0100] "GET /directory1/Pagename1;jsessionid=00JSN0M5XEY+uo?productId=41104&E_mp=2101001000002-12&strAddress=&strLocation=montmirail&strCP=&strCountry=EUR HTTP/1.1" 200 8856
192.1.201.100 - - [09/Jan/2004:12:00:41 +0100] "GET /directory2/pagename2;jsessionid=0000GH320M5XEY+uo HTTP/1.1" 200 15616
192.1.201.100 - - [09/Jan/2004:12:01:10 +0100] "GET /directory2/pagename2;jsessionid=0000GJSN0M5XEY+upouo?from=0&rnd=10736400&E_mp=2105040103fra541104130x1103EUR000ebW9udG1p0002-12&stat=ambiguous_tourism&strChoice=0 HTTP/1.1" 200 34638
192.1.201.100 - - [09/Jan/2004:11:59:20 +0100] "GET /directory1/pagename2;jsessionid=0000LILFAAGRJGG1SWYNGKQUYZI+upoplruo?&E_mp=210504cGFyaXM000edHJhaW4gYmxldQ12091172.352671212&strLocation=Paris&stat=ambiguous_tourism&strCountry=1424&strAddress=&strCP=75000&productId=41102 HTTP/1.1" 200 16066
For this example, I want to write field 1 to 6,
for the field 7, only the part before ";jsessionid=..." and for the parameters (and values) after "?" only "&stat=value" and "&productId=value"
and all the fields after the field 7 (it's possible that the number af fields change between the differents lines)
The result for my example should be :
192.1.201.100 - - [09/Jan/2004:12:01:05 +0100] "GET /directory1/Pagename1?productId=41104 HTTP/1.1" 200 8856
192.1.201.100 - - [09/Jan/2004:12:00:41 +0100] "GET /directory2/pagename2 HTTP/1.1" 200 15616
192.1.201.100 - - [09/Jan/2004:12:01:10 +0100] "GET /directory2/pagename2?stat=ambiguous_tourism HTTP/1.1" 200 34638
192.1.201.100 - - [09/Jan/2004:11:59:20 +0100] "GET /directory1/pagename2?stat=ambiguous_tourism&productId=41102 HTTP/1.1" 200 16066