DEV Community

Using Regular Expressions to Filter Your Server’s Logs

Nočnica Mellifera on August 09, 2019

Did you enjoy my introduction to Regular Expressions (RegEx)? Let’s use some to do some actual work. Here’s a classic problem You run a...
Collapse
 
learnbyexample profile image
Sundeep • Edited

quick question, which grep allows you to use \d? as far as I know, only GNU grep with -P option (PCRE) will allow it, otherwise you have to use [0-9] or the POSIX character set [:digit:] inside a character class

also, ERE is enabled using -E not -e, from GNU grep's man page:

   -e PATTERNS, --regexp=PATTERNS
          Use  PATTERNS  as  the  patterns.   If  this  option  is used multiple times or is combined with the -f
          (--file) option, search for all patterns given.  This option can be used to protect a pattern beginning
          with “-”.

   -E, --extended-regexp
          Interpret PATTERNS as extended regular expressions (EREs, see below).
Collapse
 
petengdedet profile image
Peteng Dedet

Hi, i did similar project using python github.com/PetengDedet/Ubuntu-Auth...

Collapse
 
nocnica profile image
Nočnica Mellifera

this is a lot neater than my thing, I'll have to try to run it some time! Thanks for sharing!