|
WareLogging, sort of. Regular expressions are wonderful (and wonderfully ugly) little creatures used to describe patterns in text. Useful in good TextEditors, or in a language like PerlLanguage. This page is a repository of useful regex stuff.
|
|
|
|
= resources =
|
|
|
|
* LinuxInANutshell, 2nd edition
|
|
** p. 69, grep
|
|
** p. 247, pattern matching
|
|
** p. 208, perl quickref regex section
|
|
|
|
= WareLogging =
|
|
|
|
* PerlCompatibleRegularExpressions
|
|
|
|
= thoughts & recipes =
|
|
|
|
An EvolvingRegularExpression
|
|
|
|
Use egrep for complex expressions. Otherwise you will have to escape ?, +, {, |, (, and ) in order to get them to behave as special characters. If you're used to writing in Perl or similar, keep in mind that vi / VimEditor pattern matching will treat at least some of these characters as literals unless you escape them.
|
|
|
|
(?<! ''regex'') ''other stuff''
|
|
is a zero-width negative lookbehind assertion. Matches, in
|
|
other words, if ''regex'' does *not* precede the ''other stuff''.
|
|
|
|
egrep -ri "^[a-z., ]+$" ./*.dir
|
|
Shows lines which are just alphanumeric plus period,
|
|
comma, and space characters in all files with
|
|
the extension .dir.
|
|
|
|
tail -f /var/log/p1k3.access_log | egrep -vi "(googlebot|slurp)"
|
|
following log file, wanted to avoid bot traffic noise
|
|
may well eat CPU.
|