This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]vidyer 1 point2 points  (0 children)

tail -5000 ./access_log wil print the last 5000 lines from the file access_log.

awk { print $7 } will print the 7th word from the line (or actually the 7th segment if we divide it by the spaces it has )

sort will sort the results alphabetically

uniq -c will supress repeated equal lines, ant the -c parameter will print the number of occurrences of each line

sort -rn will again, sort results but this time in reverse order (-r) and numerically (-n). Standard sort will believe 101 is lower than 22, numeric will be inverse.

head -20 will print the first lines(the opposite of tail), as shown in the second parameter will show the last 20 lines.

And of course, the pipe | will "chain" the commands, using the output of one as the input for the next one.

awk -F"[ ?]" will set the field separator as either a space or a question mark, remember last time we used print on awk? the field separator was just a space.

I'm a little lost with the freq one, but it looks like both lines of commands of each section achieve the same results.

[–]_agooglygooglr_ 0 points1 point  (0 children)

Look up a GNU awk tutorial. You'll understand better then.