Im less, version 590, I can enter as search pattern \( to search for an open parenthesis.

And I can enter # (hash character) to search for this.

But when I have to search for both two characters, open parenthesis followed by hash character, I cannot accomplish this.

How can I input this?

2 Answers 2


From less manpage, we understand that :

The pattern is a regular expression, as recognized by the regular expression library supplied by your system.

Whatever the library supplied, parentheses are special characters that should be escaped when needed as a literal by the mean of an immediately preceding backslash.
Within less, you then might find your way keying :

  • Quite natural. But that did not work (othewise I had not asked). Regards. Dec 17, 2022 at 19:33
  • @AntonWessel : Then please post what less -V outputs. At the right of the version number should the regular expression library used be displayed. As on mine : less 608 (PCRE2 regular expressions)
    – MC68020
    Dec 17, 2022 at 19:52
  • there was a typo: in my question you should read: one backslash and left paranthesi, open bracket "\(" -- your editor behaves differently in title vs normal txt. Dec 18, 2022 at 23:00
  • more in detail: the behavior of your buggy editor differs for title vs body. Dec 19, 2022 at 8:06
  • Your requirement to post what less outputs: (a) less --version shows: Dec 19, 2022 at 8:13

less treats its search strings as extended regular expressions. On top of that as seen if man less, !, * and @ are treated specially if entered at the start.

So, all 3 (and some control characters) plus all the characters that are special in the ERE syntax ($^*()+{}.?\|) need to be escaped if they're to be taken literally.

Alternatively, you can use Ctrl+r (one of those control characters to switch from a regex matching to a substring search. You'll see the prompt will change from / to Regex-off /.

The !, @, * (and ^R and other control characters) are still special at the start though.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .