If I have LESS='-FRX' as a default environment variable, how can I, as an exception to the rule, run less with only -R, ie. override/nullify -FX?
2 Answers
The options specified in LESS can be overridden by options on the command line. You can't however prevent less from using the options in LESS that you don't explicitly override without changing this variable.
One way to run less with a (temporarily) modified value of LESS would be to use
LESS= less -R filename This would call less -R with an empty value in LESS.
Or
LESS=-R less filename which would call less with LESS set to -R only.
- Nice! This is quite an acceptable solution!forthrin– forthrin2019-02-02 12:03:22 +00:00Commented Feb 2, 2019 at 12:03
- @Kusalananda is
-+a recent feature? - see my answer belowlaktak– laktak2020-09-25 19:16:11 +00:00Commented Sep 25, 2020 at 19:16 - 1@laktak It's not a recent feature. The variant of
lessthat I've been using (on OpenBSD) has had that since at least 2003.2020-09-25 21:05:24 +00:00Commented Sep 25, 2020 at 21:05
If you have defined LESS='-FRX' you can override/disable the FX options with
less -+FX This is listed in the less man page:
The environment variable is parsed before the command line, so command line options override the LESS environment variable. If an option appears in the LESS variable, it can be reset to its default value on the command line by beginning the command line option with "-+".