Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

It is normally nice to have color output from ls, grep, etc. But when you don't want it, is there a switch that can turn it off? ls -G turns it on (with 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?

share|improve this question

3 Answers 3

up vote 9 down vote accepted

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.

share|improve this answer
    
You could also use command ls, of course, but this is a little faster. –  iconoclast Jan 1 at 19:45

With GNU ls, you can specify ls --color=never to explicitly disable color output. (Even if you have an alias ls='ls --color=auto', when you run ls --color=never, it will expand to ls --color=auto --color=never, and the later option takes precedence.)

share|improve this answer
    
This is really the answer I was looking for, but I'll keep slm's answer as the chosen one since it handles cases of non-GNU ls, like BSD-derived versions (OS X, Solaris, and of course *BSD). –  iconoclast Jan 1 at 16:42
alias ls=ls

or

unalias ls

This disables permanently the colorings.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.