A Perl one-liner to count regex matches

Use this at the command line — it means you can use nice perl regular expressions rather than the horrible grep and sed ones that make my eyes bleed.

Of course, it’s entirely possible that perl regexes will make your eyes bleed.

 grep replacement

grep -c replacement

Both of these come from the invaluable Perl One-Liners Explained by Peteris Krumins. Depending on your point of view, this is perl at its best or worst.

Blog comments powered by Disqus