egrep pipe example on Apache access log

Some egrep pipe examples for Apache access logs on Ubuntu Linux

egrep http status code 301 entries

$ cat /var/log/apache2/access_log.2015-11-29 | egrep " 301 "

egrep http status code 301 or 302 entries

Approach 1

$ cat /var/log/apache2/access_log.2015-11-29 | egrep " (301|302) "

Approach 2

$ cat /var/log/apache2/access_log.2015-11-29 | egrep " 30(1|2) "

Note the presence of brackets on both approaches.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments