I'm searching how to put for loop inside "print" - I've managed how to get all information what I need from log file but if I use "for loop" after print then each new information is given in new line. I know that is calling print each time so... how to print all in new line? For example this:
cat /var/log/apache2/domlogs/xxxx/xxxx.com* | awk -F " " '{print $1 " - " $4 " " $5 " "} {for(i=12; i<=NF; i++) print $i}'
Give me that output:
66.249.65.172 - [29/May/2019:02:48:20 +0200]
"Mozilla/5.0
(compatible;
Googlebot/2.1;
+http://www.google.com/bot.html)"
But when I want to pass at end what I found between 12 col and NF:
cat /var/log/apache2/domlogs/xxxx/xxxx.com* | awk -F " " '{print $1 " - " $4 " " $5 " " for(i=12; i<=NF; i++) " " $i}'
Then I get only:
66.249.65.172 - [29/May/2019:02:48:20 +0200]
I'm heading to output like:
66.249.65.172 - [29/May/2019:02:48:20 +0200] "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"