Could someone give me a quick simple explanation for the AWK command.
And also help me to explain the code i have made. I have made some general comments about it myself. I was wondering if people could help me with the rest:
awk -F'[: ]' 'END {
fmt = "%-20s\t%s\t%s\n" # Formats the table output
printf fmt, "Page:", "Hits:", "Unique Hits:" # Defines Column Headers
for (p in h)
printf fmt, p, h[p], u[p]
}
!_[$1,$2]++ { u[$1]++ } # u[x] counts the number of occurrences of x in field column 1.
{ h[$1]++ }' HITS | # h[x] counts the number of occurrences of x in field column 1.
( IFS='' read header; echo "$header"; sort -k2rn ) # discard any duplicates where same combination of column 1 and 2 has been seen before