4

On my Linux machine - I do the following:

$ env | grep -i LESSOPEN
LESSOPEN=|/usr/bin/lesspipe.sh %s

So from env command I see that:

LESSOPEN=|/usr/bin/lesspipe.sh %s

I want to change the variable LESSOPEN, so I do the following search in order to find where it's located, so I can make this change.

$ grep -Ril "LESSOPEN" /

But the grep search did not find any such file with LESSOPEN.

  • Which distribution are you running? Which version? The files that define these things vary greatly between different distributions. – Didi Kohen Sep 11 '14 at 13:59
  • DAVID MA SLOMAHA , first - my linux version is 5.3 , I run the find command from the "/" , and I really not understand why find + grep not found this param – maihabunash Sep 11 '14 at 14:08
  • Are you sure this didn't find a hit? grep -R … / would spew out a lot of errors and run for a very long time because it traverses all filesystems and tries to enter directories and read files that you have no permission to read. – Gilles Sep 12 '14 at 14:50
9

On Red Hat and CentOS systems, it is defined in /etc/profile.d/less.sh. On version 5, this contains

# less initialization script (sh)
[ -x /usr/bin/lesspipe.sh ] && export LESSOPEN="${LESSOPEN-|/usr/bin/lesspipe.sh %s}"

On other systems, such as version 7, the value may be ||/usr/bin/lesspipe.sh %s; there is a slightly different interpretation between values that begin with | and ||, detailed in the man page for less.

You can either edit that file if you want all users of bash-like shells on your system to see a different value, or override it for yourself by editing ~/.bashrc or ~/.bash_profile to have an export LESSOPEN=whatever line.

On Linux systems, grep -r string / or grep -R string / may run into problems when reading certain special files. grep will hang when reading /dev/rfkill, and, due to what I believe is a buffer allocation bug, will run out of memory reading certain large files in /proc. An alternative is to exclude /dev and /proc:

find / '(' -path /proc -o -path /dev ')' -prune -o -type f -exec grep -il lessopen {} +

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.