Where is less search pattern reference?
less
's man page says:
/pattern
Search forward in the file for the N-th line containing
the pattern. N defaults to 1. The pattern is a regular
expression, as recognized by the regular expression library
supplied by your system.
so the accepted syntax may depend on your system. Off-hand, it seems to accept extended regular expressions on my Debian system, see regex(7)
, and Why does my regular expression work in X but not in Y?
\d
is from Perl, and isn't supported by all regex engines. Use [0-9]
or [[:digit:]]
to match digits. (Their exact behaviour may depend on the locale.)
The expressions supported by less
are documented in the re_format(7)
manual (man 7 re_format
). That manual describes both the extended regular expressions and the basic regular expressions available on your system. The less
utility understands extended regular expressions.
To match a digit, you would use [0-9]
or [[:digit:]]
(there's a slight difference as the former depends on the current locale). The \d
pattern is a Perl-like regular expression (PCRE), not supported by less
.