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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking at this short example, and I don't see how this function works:

function EXT_COLOR () { echo -ne "\[\033[38;5;$1m\]"; }

AFAIK -ne stands for not equal. What are we comparing here? I only see one variable (string): "\[\033[38;5;$1m\]". It looks like it echoes the result of comparison, but there is no variable it compares to.

share|improve this question
Nope, nothing to do with programming. – bahamat Sep 20 '11 at 19:22
up vote 6 down vote accepted

-ne only means "not equal" when it's in an if [ … ] statement. In this case -ne is an option to echo. You could just as easily use -en.

From bash(1):

If -n is specified, the trailing newline is suppressed. If the -e option is given, interpretation of the following backslash-escaped characters is enabled.

In this example there is no comparison. Just echo.

share|improve this answer
Possibly more clearly, you could also just as easily use "-n -e" -- it's two options, echo just supports merging them together under a single dash because it's unambiguous – Michael Mrozek Sep 20 '11 at 21:11

Your Answer


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.