Parse compressed apache error log file and show top errors

zcat error.log.gz | sed 's^\[.*\]^^g' | sed 's^\, referer: [^\n]*^^g' | sort | uniq -c | sort -n
credit shall fall to this for non-gzipped version: https://gist.github.com/marcanuy/a08d5f2d9c19ba621399
Sample Output
   1  AH00126: Invalid URI in request GET  HTTP/1.1
      1  PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in /var/www/con/libraries/joomla/database/driver/mysql.php on line 425
    108  PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 512 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
    156  PHP Notice:  Undefined index: select in /var/www/con/cli/form_output.php on line 3
    156  PHP Notice:  Undefined index: inputfrom_value in /var/www/con/cli/form_output.php on line 2
    157  PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 83 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
    202  PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
    218  PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 80 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425
    316  PHP Notice:  Undefined index:  in /var/www/conven/cli/units.php on line 513
    520  PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 81 bytes) in /var/www/es/libraries/joomla/database/driver/mysql.php on line 425

1
By: zanhsieh
2014-09-24 05:26:24

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: