1

I would like to use a perl compatible regex engine in the less command line utility. Is that possible?

drevicko
  • 313
  • 2
  • 9

1 Answers1

2

Not out of the box. What you can do as a substitute is to send the input to grep --perl-regexp (or -P) before piping it to less, for example:

some_command | grep -P … | less

If you want to see the rest of the file as well, with the matches highlighted, you can use this trick and pipe the result to less --raw-control-chars (or -r).

l0b0
  • 50,672
  • 41
  • 197
  • 360
  • Suspected as much, thanks for confirming. I always forget which regex idiosyncrasies apply in which command line tool, and have a bad habit to lean on Perl regex niceties ): – drevicko Sep 11 '20 at 02:59