Asked • 07/29/19

Pcregrep vs Perl vs Python for bash scripting when needing advanced regex features?

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?

1 Expert Answer


Dan S. answered • 10/02/19

4.9 (48)

Senior Systems Engineer Specializing in Linux

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.