Censorship and old less

Karl Auer kauer at biplane.com.au
Wed Nov 7 23:41:38 UTC 2018

On Wed, 2018-11-07 at 16:17 -0500, J wrote:
> On Wed, Nov 7, 2018 at 3:40 PM <hatemailer4u at cock.li> wrote:
> Long Rambling invective laden diatribe snipped
> Perhaps if you treated the readers of this list with the same respect
> you seem to demand, you'd be taken more seriously?

Indeed. This is my standard response to such muppets:


It offends me to give the little nasty what he wants, so hopefully this
isn't good enough for him:

Put this in a script or alias and call it e.g. lless:



if [ -z "$1 ] ; then
   echo "No file to display."
   exit 0

L=`tput lines`
W=`tput cols`
F=`wc -l < "$1"`
LL=`wc -L < "$1"`

# If the longest line is longer than the
# terminal width, use ordinary less
if (( $LL > $W )) ; then
      less "$1"
   # Otherwise, if the whole thing will fit
   # on the terminal, exit after display
   if (( $L < $F )) ; then
      less "$1"
      less -F -X "$1"


That will output all lines and exit without clearing the screen if the
number of lines in the first and only argument is less than the number
of lines in the terminal window AND the longest line will fit in the
terminal width. Written without any testing, so use with care!

If you don't care about lack of mousewheel scrolling, just use "less -F
-X file.txt"

Or update to the latest less :-)

Regards, K.

Karl Auer (kauer at biplane.com.au)

GPG fingerprint: A0CD 28F0 10BE FC21 C57C 67C1 19A6 83A4 9B0B 1D75
Old fingerprint: A52E F6B9 708B 51C4 85E6 1634 0571 ADF9 3C1C 6A3A

More information about the ubuntu-users mailing list