mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-22 08:22:08 +02:00
perl: add PCRE one liner example (#3129)
This commit is contained in:
parent
66dd8e6acc
commit
ec2213a34a
1 changed files with 4 additions and 0 deletions
|
@ -30,3 +30,7 @@
|
||||||
- Run a multi-line find/replace expression on a file, and save the result in another file:
|
- 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}}`
|
`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;}'`
|
||||||
|
|
Loading…
Add table
Reference in a new issue