I've lately been using pcregrep to do Perl-style group matching when doing my bash scripts.

The problem with pcregrep is that it's not readily available on Linux machines in general.

An alternative would be to run Perl one liners or maybe, if possible, Python one liners to do those matches.

I was wondering how good of an approach would this be? I don't know how fast both Perl and Python are initializing, as I can imagine that if my script has to consecutively make Regex matches and every time it needs to spawn a new instance of either Perl or Python, things can go slow fast. On the other hand, I don't feel like investing at the moment on learning the full languages, so I can do the whole script in them (Perl seems to be mostly a dead language, Python is the new king).

How do you guys deal with this (or similar?) situations?

  • 2
    I don't know how fast both Perl and Python are initializing... -- There's a way to find out. Jul 31, 2016 at 0:14
  • Ok, stackoverflow.com/questions/12793562/…. My question is still the same. What are the real world alternatives people are using to avoid using pcregrep? Jul 31, 2016 at 0:23
  • 2
    perl -ne 'print if /regex/' is a quick+dirty grep using perl regex. Try yourself if the speed is enough for you. Jul 31, 2016 at 5:39
  • 3
    "Perl seems to be mostly a dead language"... yeah right. As dead as Java and C++ I hazard.
    – Martin Ba
    Aug 2, 2016 at 9:44
  • 4
    @devouredelysium - /me: chuckles. Even if I would take that index for anything, it's in the top ten FCS. About as popular as JavaScript, and like that is dead.
    – Martin Ba
    Aug 2, 2016 at 19:13

1 Answer 1


Unless you work with some very arcane systems then if the remote system has bash, it will have Perl as well. A considerable amount of all the core utilities on almost all Linuxes are written in Perl after all.

If you want Perl functionality, write your stuff in Perl. It's available and gets the job done.

Whether you consider it to be a dead language1 or not doesn't make a difference for that decision. You can still use it if it's available and gets the job done. You want strong regular expressions and availability. It gives you both. You don't even need to learn a lot of syntax for the stuff you want to do. If you can solve it in bash, you can also easily do it in Perl.

1) I disagree strongly as Perl has successfully paid my rent for the last 10 years and continues to do so

Not the answer you're looking for? Browse other questions tagged or ask your own question.