Kudithipudi.Org

September 5, 2012

HOW TO : grep for response codes in apache logs

Filed under: HOWTO,Linux,Web — Vinay @ 8:51 am

If you want to grep for certain http response codes in a apache log file

  • Look for all access requests with a 200 response code
     grep -i "[: ]200[: ]" HTTP_ACCESS_LOG 
  • Look for all access requests that do NOT have a 200 response code
     grep -i -v "[: ]200[: ]" HTTP_ACCESS_LOG 

Details of the options

  • "[: ]"

    tells grep to look for space or tab before the specified string, which in this case is 200.

Powered by WordPress