MDLog:/sysadmin

The Journal Of A Linux Sysadmin

Or Operator for Grep

| Comments

For grep expressions the OR operator is ”\|”. Here is an example using tail on a file looking for 2 strings occurrences:

1
tail -f /var/log/apache2/error.log | grep "PHP Notice**\|**client denied"

or another example to list the content of the php.ini file without comments and empty lines:

1
grep -v "**^#\|^$\|^;**" /etc/php5/apache2/php.ini

Comments