Simple command line grep usage to understand complex regular expressions
I was looking for a simple method to understand regular expressions. In this particular case it was to analyze an ignore rule used by logcheck log monitoring tool. I knew that the Linux environment offered some powerful tools to use regular expressions, but I was looking for a simple pass in this string and show me what matches via my regular expression. After quite a bit of time looking at man pages for grep, I initially didn't find the simple solution that I was hoping to... AMD-ubuntu /USR/SBIN/CRON[9999]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) And it was ignored by the entry in /etc/logcheck/ignore.d.paranoid/cron ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ /USR/CRON\[[0-9]+\]: \([_[:alnum:]-]+\) CMD \(.*\)$ The log entry I wanted to ignore was: Nov 2 19:17:01 AMD-ubuntu CRON[6877]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) The regular expression that I ended up using to ignore my routine CRON job log entries was: ^\w...