bash - Troubling figuring out one part of this script -


i'm new this, think easy question.

i have following script given me go through our logs , pull out information:

awk ' match($0, /"username":"[^"]*"/) {         split($3, d, "@")         user = substr($0, rstart + 12, rlength - 17)         split(user, e, "@")         c[e[2] "," d[1] "," e[1]]++ } end {   for(i in c)                 printf("%d,%s\n", c[i], i) }'      mycompany.log | sort -t, -k2,2 -k3,3 -k4,4 

what script goes through log entries, , entry corresponds username grabs date, username, organization , number of unique entries user on date. pretty understand how works of these values except number of entries per user (can't figure out in script this).

basically right output sorted in columns:

number of entries, organization, date, username

like this:

609,organization,05-22,someuserfromthatorganization 

and want this:

organization,05-22,someuserfromthatorganization,609 

but mentioned i'm unsure how/where in script number calculated can't figure out how that.

the associative array c contains count of entries each user on date. e[2] "," d[1] "," e[1] concatenates organization, date, , username. used key in c array c[e[2] "," d[1] "," e[1]]. finally, ++ increment operator makes count repetitions of this.

at end prints contents of array.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -