Prevent ANSI escape sequences in terminal output

puttyterminalvt100

When I do an "ls -l" on my linux box over PuTTY, it gives a clean, nicely colored output.

But when I try the same programmatically over plink, I land up getting all sort of control sequences, likely signifying those color values.

Can I somehow set the terminal options so that it doesn't send out these extra sequences for the colors, and just emits plain text?

[00mtotal 8956
drwxr-xr-x 8 pradymn users    4096 2010-07-23 12:29 [01;34mtestsb1[00m
drwxr-xr-x 5 pradymn users    4096 2010-07-24 22:49 [01;34mtest1[00m
-rw-r--r-- 1 pradymn users 9143013 2010-07-24 23:03 [00;31mtest1.tar.gz[00m

Best Answer

This is probably related to how you setup your ls to display colors. If you can post that we might be more helpful.

I recommend using the following in your favorite shell profile file (.bashrc): alias ls="ls --color=auto"

Alternatively when you don't want color output you can call ls using --color=never

Related Question