6

I set and exported $LESSHISTFILE and $LESSHISTSIZE but if I perform a search in one less session, close, reopen it and try to repeat my last search I get "No previous regular expression (press RETURN)".

It works as expected in Ubuntu 14.04 but not in Fedora release 7. Any suggestion?

It's writing to $LESSHISTSIZE. I get the same text written to the history file on both Ubuntu and Fedora. Below I started with an empty history file and then executed cal | less. I searched for "xxx" while in less. But when I exit and rerun the less command it gives me the error message if try to repeat the search with just the / command.

$ cal | less
$ ls -l  $LESSHISTFILE
-rw------- 1 cs cs 40 Aug  4 14:23 .lesshist
$ cat  $LESSHISTFILE
.less-history-file:
.search
"xxx
.shell
$ 

Maybe it's because the version on Fedora is so old.

$ less --version
less 394
Copyright (C) 1984-2005 Mark Nudelman
2
  • Where are you exporting these variables, and do they show inside env output? If so, what happens when you run touch $LESSHISTFILE?
    – Drav Sloan
    Aug 4, 2015 at 14:54
  • Thanks. I verified that it does write to the history file. That surprised me. I added an example above.
    – JohnMudd
    Aug 4, 2015 at 18:39

1 Answer 1

3

Ubuntu 14.04 has less 458, and Fedora 7 has less 394. The NEWS file between those versions is the place to look:

            Major changes between "less" versions 394 and 406

    * Allow decimal point in number for % (percent) command.

    * Allow decimal point in number for -j option (fraction of screen height).

    * Make n command fetch previous pattern from history file on first search.

For that, you have to look at the sources (I'm looking at the file from less 451), because the online history doesn't go back that far. You can get older versions from ftp://ftp.gnu.org/gnu/less/

Since answering this in 2016, the RCS for less was exported to git here, apparently in mid-2017, and one can point more accurately to the change (early 2007). Exactly when the switch was done is unclear, since the repository commits are unverified.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.