From ec2213a34a4ea27734311be403b2664fce782255 Mon Sep 17 00:00:00 2001 From: Zachary Sherwin <48960849+hello-woof@users.noreply.github.com> Date: Tue, 24 Sep 2019 06:00:09 -0700 Subject: [PATCH] perl: add PCRE one liner example (#3129) --- pages/common/perl.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pages/common/perl.md b/pages/common/perl.md index 924cdc7db..2b59ec5e2 100644 --- a/pages/common/perl.md +++ b/pages/common/perl.md @@ -30,3 +30,7 @@ - Run a multi-line find/replace expression on a file, and save the result in another file: `perl -p0e 's/{{foo\nbar}}/{{foobar}}/g' {{input_file}} > {{output_file}}` + +- Run a regular expression on `stdin`, printing out first capture group for each line: + +`cat {{path/to/input_file}} | perl -nle 'if (/.*({{foo}}).*/) {print "$1"; last;}'`