6

Recently I've noticed that less command doesn't work.

$ ls | less                                                        
CertificateEntreprenuership101.pdf
Engineering Software as a Service_ An Agile Approach Using Cloud Computing_B00CCEHNUM copy.azw3
Photos.zip
Raspberry_Pi_Education_Manual.pdf
chef-v100
chef-v100.zip
node-webkit
postgresql-v400 2
postgresql-v400.zip
rd1_ua
rd1_ua.zip

As you can see it didn't open less as viewer. It might be some global setting but I have no idea what might it cause.

Update.

$ which less
/usr/bin/less
$ echo $LESS                                                           
-F -g -i -M -R -S -w -X -z-4
less <somefile> - works as expected
  • 3
    Is LESS set in the shell? What does echo $LESS return? Does less some-text-file work as expected? – nohillside Jun 26 '16 at 14:46
  • Why are some parts of the output in blue?! – Nicolas Barbulesco Jun 26 '16 at 18:41
  • 2
    @NicolasBarbulesco That’s the Always Perfect™ default syntax highlighter. – J F Jun 26 '16 at 20:29
11

From man less:

   -F or --quit-if-one-screen
          Causes  less  to  automatically  exit  if  the entire file can be displayed on the first
          screen.

Remove the option from LESS to avoid this.

  • 2
    Please point me to the documentation of 'echo $LESS', i've never heard of this expression. – megas Jun 26 '16 at 15:06
  • 3
    echo is a shell command which prints all its arguments (try echo Hello World). LESS is a variable defined in your shell which can be addressed as $LESS. Combining this together you can use echo $LESS to display the content of this variable. – nohillside Jun 26 '16 at 15:18
  • 1
    Why is the word “Causes” in blue? Strange. – Nicolas Barbulesco Jun 26 '16 at 18:44
  • 2
    @Nicolas Because it's the start of the line and the first letter is capital. The ‘default’ syntax highlighting style colours such text as blue. – grg Jun 26 '16 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .