awk grouping by name script

Hello

I am trying to figure out a script which could group a log file by user names. I worked with awk command and I could trim the log file to:

<USER: John Frisbie > /* Thu Aug 06 2009 15:11:45.7974 */ FLOAT GRANT WRITE John Frisbie (500 of 3005 write)
<USER: Shawn Sanders > /* Thu Aug 06 2009 15:11:49.7695 */ FLOAT GRANT WRITE Shawn Sanders (552 of 3004 write)
<USER: John Frisbie > /* Thu Aug 06 2009 15:12:02.3639 */ LOGIN John Frisbie

But I need to have the output like:

Users
John Frisbie
FLOAT GRANT WRITE Thu Aug 06 2009 15:11:45.7974 (500 of 3005 write)
LOGIN Thu Aug 06 2009 15:12:02.3639

Shawn Sanders
FLOAT GRANT WRITE Thu Aug 06 2009 15:11:49.7695 (552 of 3004 write)

I have tried commands like:

awk 'BEGIN{print "Users"} {a[$2]=a[$2]+[$3]}END{for (i in a) printf(i,a, $5,$6,$7,$8,$9,$11,$12,$13,$14,$15]} ' log

or

User= $1,$2
awk '{if ($1,$2 == "User")print $5,$6,$7,$8,$9,$11,$12,$13,$14,$15}' log

But after several results it seems that I am completely lost. I am not sure how can I group the user ids by name and then display the user name only once and below of it all the information associated .

If you could please provide your advice I will appreciate it.

Thanks!

something to start with:

nawk -F'/' '{u[$1]; f2[$1]=($1 in f2)? f2[$1] ORS $2:$2; f3[$1]=($1 in f3)? f3[$1] ORS $3:$3} END {for(i in u) print i ORS f2 ORS f3}' myLog
1 Like

Wow!:eek:

Works like magic. Thank you :b:. So it is time for me to review it and understard it. I have still too much to learn