4 ms·
My personal favorite is to use this pattern. You can do some extremely cool counts and group by operations at the command like [1]: grep '01/Jul/1995' NASA_a
by WestCoastJustin 12y ago
My personal favorite is to use this pattern. You can do some extremely cool counts and group by operations at the command like [1]:
grep '01/Jul/1995' NASA_access_log_Jul95 |
awk '{print $1}' |
sort |
uniq -c |
sort -h -r |
head -n 15
Turns this:
199.72.81.55 - - [01/Jul/1995:00:00:01 -0400] "GET /history/apollo/ HTTP/1.0" 200 6245
unicomp6.unicomp.net - - [01/Jul/1995:00:00:06 -0400] "GET /shuttle/countdown/ HTTP/1.0" 200 3985
199.120.110.21 - - [01/Jul/1995:00:00:09 -0400] "GET /shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0" 200 4085
burger.letters.com - - [01/Jul/1995:00:00:11 -0400] "GET /shuttle/countdown/liftoff.html HTTP/1.0" 304 0
199.120.110.21 - - [01/Jul/1995:00:00:11 -0400] "GET /shuttle/missions/sts-73/sts-73-patch-small.gif HTTP/1.0" 200 4179
Into this:
623 piweba3y.prodigy.com
547 piweba4y.prodigy.com
536 alyssa.prodigy.com
463 disarray.demon.co.uk
456 piweba1y.prodigy.com
417 www-b6.proxy.aol.com
350 burger.letters.com
300 poppy.hensa.ac.uk
279 www-b5.proxy.aol.com
[1] https://sysadmincasts.com/episodes/28-cli-monday-cat-grep-awk-sort-and-uniq https://sysadmincasts.com/episodes/28-cli-monday-cat-grep-aw...
- vram22 12y agoI think there's something like that in the Kernighan and Pike book I referred to elsewhere in this thread, and also, that code looks similar to this technique: http://en.wikipedia.org/wiki/Decorate-sort-undecorate http://en.wikipedia.org/wiki/Decorate-sort-undecorate , i.e. Decorate-Sort-Undecorate (DSU), related to the Schwartzian transform.
- prlin 12y agoSimilar ideas in Python with Generators and Co-routines: http://www.dabeaz.com/generators-uk/ http://www.dabeaz.com/generators-uk/