[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: binary output from ls



Ivan Glushkov wrote:
David Kirchner wrote:

On 2/15/06, Ivan Glushkov <glushkov@mail.desy.de> wrote:
Hi,
if I issue ls . > filelist.txt
as user I get:
a binary file like:

ESC[0mESC[0mAcro3nKTzaESC[0m
ESC[0mfilelist.logESC[0m
ESC[01;34mgconfd-glushkovESC[0m
ESC[01;34mkde-glushkovESC[0m
ESC[01;34mkeyring-CXhOCWESC[0m
ESC[01;34mksocket-glushkovESC[0m
ESC[01;35mmapping-glushkovESC[0m
ESC[01;34morbit-glushkovESC[0m
ESC[01;34mssh-mmCRYB8783ESC[0m
ESC[01;35mxmms_glushkov.0ESC[0m
ESC[0mzmanImD0upESC[0m
ESC[m
...

if I do that like root, I get the list of files as expected.
What is the difference? Both root and the user are using the same shell.


Unfortunately, by default, ls uses colors to highlight directories and
executables (and others). The default alias provided in .bashrc, with
a stock install, is 'ls --color=auto'. auto is supposed to tell ls to
ensure it is connected to a tty (instead of a file) before spitting
out colors. If that alias is 'ls --color=always', it will always use
colors, regardless of the output.
The solution will be found in your .bashrc file -- either change the
alias to 'ls --color=auto' or remove it entirely, and it should work
OK.


Thank you all,

Just for the record:
I am using zsh, and I was having in my ~/.zshrc the following line:

alias "ls=ls --color"

now I changed that to:

alias "ls=ls --color=auto"

and everything looks fine.

For those cases where you don't/can't see color, you may
find that the -F option to ls gives you the same information,
if in not quite so obvious a way. I used to use -F all the time,
and had it aliased that way permanently.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
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!



Reply to: