Retrieve log pattern via awk

Viewed 51

I would like to retrieve from the following logs the date, the 5 URI length, the ab and cde:

10.10.10.10 - - [26/Oct/2020:19:50:13 +0000] "GET /five/six/seven/eight/nine/en?from=1603738800&to=1603785600ncludedInRange=false HTTP/1.1" 200 255441 "-" "Opera com.test.super/1.10.4;11072 (Linux;Neon KNWWWfj;0,02.2)" "10.10.10.10""f799b6b9-747f-4f22-a1bf-4b7de885fc60""-" "-" "-" "-"ab=0.110 cde=0.102
11.1.1.1 - - [26/Oct/2020:19:50:14 +0000] "GET /one/two/three/four/five/en HTTP/1.1" 200 2832 "-" "Opera com.test.super/1.10.4;11072 (Linux;Neon KNWWWfj;0,02.2)" "11.1.1.1""19a8ee3c-9cb3-4ba6-9732-eb4923601e92""-" "-" "-" "-"ab=0.111 cde=0.112

e.g.

26/Oct/2020:19:50:13 /five/six/seven/eight/nine ab=0.110 cde=0.102

I have tried the following command, but I get only a part of it. Can you please help?

awk '{print $4 "\t" $7 "\t" $(NF-1),"\t",$NF}' |sed 's/"-"//g'
2 Answers
$ awk -F'[][[:space:]"]+' -v OFS='\t' '{match($7,"(/[^/]*){5}"); print $4, substr($7,1,RLENGTH), $(NF-1), $NF}' file
26/Oct/2020:19:50:13    /five/six/seven/eight/nine      ab=0.110        cde=0.102
26/Oct/2020:19:50:14    /one/two/three/four/five        ab=0.111        cde=0.112

Based on @Ed Morton, but setting FS in 5 parts:

$ awk -v FS='[[]|\\+[[:digit:]]+[]]|GET |/en|"+-"' '{print $2,$4,$NF}' file
26/Oct/2020:19:50:13  /five/six/seven/eight/nine ab=0.110 cde=0.102
26/Oct/2020:19:50:14  /one/two/three/four/five ab=0.111 cde=0.112

Updated. Thanks to @Ed Morton.

Related