6

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 2

9

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.

3
  • Nice! This is quite an acceptable solution! Commented Feb 2, 2019 at 12:03
  • @Kusalananda is -+ a recent feature? - see my answer below Commented Sep 25, 2020 at 19:16
  • 1
    @laktak It's not a recent feature. The variant of less that I've been using (on OpenBSD) has had that since at least 2003. Commented Sep 25, 2020 at 21:05
5

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 "-+".

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.