Linux LS Command – How to Turn Off Color with ls

colorsls

It is normally nice to have color output from ls, grep, etc. But when you don't want it (such as in a script where you're piping the results to another command) is there a switch that can turn it off? ls -G turns it on (with some BSD-derived versions of ls) if it's not the default, but ls +G does not turn it off. Is there anything else that will?

Best Answer

Color output for ls is typically enabled through an alias in most distros nowadays.

$ alias ls
alias ls='ls --color=auto'

You can always disable an alias temporarily by prefixing it with a backslash.

$ \ls

Doing the above will short circuit the alias just for this one invocation. You can use it any time you want to disable any alias.