Did you know that you can replace grep and sed by perl -pe and have the full power of Perl regexs?


Imagine you have a file with comma-separated Odoo module names and you want to extract all those that:

  1. Are unrelated to payment.
  2. Are from any localization except the Spanish one.

Using only grep or sed is very complicated because they don’t support negative lookaheads. However, with Perl it’s “very” easy:

$ cat example.txt

$ perl -pe "s/,?\w*(l10n_(?!es_?)|payment)\w*//g" example.txt