This is the less I am using:
less 458 (POSIX regular expressions)
Copyright (C) 1984-2012 Mark Nudelman
In Vim it is \<
and \>
, in most other regex it is \b
.
The character classes [[:<:]]
and [[:>:]]
match beginning and end of word, respectively, in system less
on OS X 10.11.5. I haven't found a way to make the documented short forms \<
, \>
, or \b
work.
(Thanks to denis for the suggestion to check man 7 re_format
.)
Your version of less
was built with posix regular expressions, as if:
wget http://ftp.gnu.org/gnu/less/less-451.tar.gz
tar zxf less-451.tar.gz
cd less-451
./configure --with-regex=posix
make
However, apparently the cause of whether \<
works or not does NOT depend on this:
\<
will work fine even if you build with the above commands, with posix regex--with-regex
except pcre
, and \<
doesn't work with any of them. If I build with pcre
, then \b
works, instead of \<
.To conclude, I don't know how to make it work with \<
. But you can build yourself with pcre
and then it should work with \b
. If you are not a sysadmin, you probably want to use a --prefix
to install under your home directory, for example --prefix=$HOME/opt
. After the make
step, confirm it works with ./less /path/to/some/file
. If looks good, then finish with make install
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With