i'd like perl to do a one-liner like grep
a bit like this, but i'm not sure what to add to make it work
$ (echo a ; echo b ; echo c) | perl -e 'a'
ADDED
My answer here covers that and more
https://superuser.com/questions/416419/perl-for-matching-with-regex-in-terminal
Performing a regex search-and-replace is just as easy: $string =~ s/regex/replacement/g; I added a “g” after the last forward slash. The “g” stands for “global”, which tells Perl to replace all matches, and not just the first one.
Regular Expression (Regex or Regexp or RE) in Perl is a special text string for describing a search pattern within a given text. Regex in Perl is linked to the host language and is not the same as in PHP, Python, etc. Sometimes it is termed as “Perl 5 Compatible Regular Expressions“.
(echo a; echo b; echo c) | perl -ne 'print if /a/'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With