Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I regularly use the 'less' command in Gentoo like so: less /tmp (or any other directory, which I have access to.)

Less then proceeds to show me the contents of that directory. I can also use Less to show the contents of files (the usual use case).

In Ubuntu (Oneiric) when executing the above command, Less reports: /tmp is a directory

Less will not list the contents of the directory.

I am using Less version 444 in both operating systems.

Can anyone help? I have been unsuccessful searching online.

Thanks in advance.

share|improve this question

2 Answers 2

Check out the README.gentoo file in

/usr/portage/sys-apps/less/files

The behavior of less is customized by a lesspipe.sh script (in that same directory). If the argument passed is a directory, lesspipe.sh does ls -alF on it and that is what less pages.

See the less man page, Input preprocessor section for additional information. You can probably pick up Gentoo's lesspipe.sh and put it on your Ubuntu system without much hassle.

share|improve this answer

Lesspipe is part of the less package on Ubuntu (Precise, at least), and is probably already installed on your computer.

Put this command in a login script, for instance ~/.bash_login:

eval $(lesspipe)

Then put this content in ~/.lessfilter

#!/bin/sh

# show directory as listing
if test -d "$1"; then
 /bin/ls -alF -- "$1"

 # we handled this one ourself
 exit 0
fi

# handle by regular lesspipe
exit 1

And make this file executable:

chmod +x ~/.lessfilter

Directories should now be shown as long format listings.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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