Last active
January 24, 2020 02:25
-
-
Save JohnL4/00d3d97afb6ef4b2a6edd8f051dcc195 to your computer and use it in GitHub Desktop.
Grab a substring out of a string with Perl. But: Perl is the road to hell. Don't do it, mon.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cat edWebLog.txt | perl -e 'while (<>) { /caching service background update finished on thread \(id 21\) in ([0-9]+) ms/ && print "$1\n";}' | |
| # Simpler: | |
| echo abc | perl -n -e '/a(.)c/ && print "$1\n";' | |
| # So, the first line becomes: | |
| cat edWebLog.txt | perl -n -e '/caching service background update finished .* in ([0-9]+) ms/ && print "$1\n";' | |
| # Note that the UNESCAPED parens are the capturing group. The escaped parens are just literal parens in the regex. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment