LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   ls colors messing up pipes (https://www.linuxquestions.org/questions/linux-general-1/ls-colors-messing-up-pipes-438064/)

Wynd 04-23-2006 01:17 PM

ls colors messing up pipes
 
When I try to do anything involving the command `ls`; I get weird escape sequences that I an guessing refer to the colors, because --color=no gets rid of them.

For example, ls / | less gives me this:
Code:

ESC[00mESC[01;34mbinESC[00m/
ESC[01;34mbootESC[00m/
ESC[01;34mdevESC[00m/
ESC[01;34metcESC[00m/
ESC[01;34mhomeESC[00m/
ESC[01;34mlibESC[00m/
ESC[01;34mlost+foundESC[00m/
ESC[01;34mmntESC[00m/
ESC[01;34moptESC[00m/
ESC[01;34mprocESC[00m/
ESC[01;34mrootESC[00m/
ESC[01;34msbinESC[00m/
ESC[01;34msysESC[00m/
ESC[01;34mtmpESC[00m/
ESC[01;34musrESC[00m/
ESC[01;34mvarESC[00m/
ESC[m

How can I fix that? I've never had this happen to me before.

ataraxia 04-23-2006 05:57 PM

You should use "--color=auto" in any aliases for ls. That way you get color when the output is going directly to a terminal, but not when it's going into a file or pipe.


All times are GMT -5. The time now is 11:34 PM.