Strange output by the "ls -l|less" command pipe in FC5

Mike McCarty Mike.McCarty at
Fri Apr 7 18:06:03 UTC 2006

Joachim Backes [RHRK] wrote:
> Mike McCarty wrote:
>> Joachim Backes [RHRK] wrote:
>>> Using "ls -l|less " in FC5 gives a strange output on a fresh FC5 
>>> installation.
>>> Using "more" instead of "less" generates correct output. Did anybody 
>>> make similar experiences?
>>> ESC[00mtotal 916
>>> -rw-r--r-- 1 root root 11942 Feb 12 09:50 ESC[00mLICENSEESC[00m
>> What you see here is the escape sequences for setting colors
>> coming out of ls. You see, "less" is translating the escape
>> sequences into graphic characters (like 0x1B is becoming "ESC").
>> Try this...
>> $ ls -l --color=never | less
>> If that looks ok (it should) try
>> $ ls -l --color=auto | less
>> That *should* also work. You may have an alias for "ls".
>> Mike
> Hi, Mike,
> You are right: there is an alias: ls='ls --color'.
> Using both options in ls cmd (--color=never or --color=auto) helps.

Mine looks like this:

alias ls='ls --color=tty'

--color=auto should also work.

Anyway, I get color when it matters. You don't want it
when redirecting ls output to a file for later processing,
which is why I recommend *against* using

ls | less -r

This trick won't work, for example, with grep.

This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!

More information about the users mailing list