Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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 have an echo statement in my script as below:

echo -ne "Check Script";

I was expecting it to print

Check Script

but I am getting the below output

-ne Check Script

But when I run the same script on some other machine I get the expected output. What could be machine specific variables or properties because of which the script is behaving differently.

share|improve this question
The operating system, the shell, and the value of shopt xpg_echo. – Mikel Nov 7 '12 at 16:26
@Mikel: Red Hat Enterprise Linux Server release 5.7 (Tikanga). Using kshell. shopt xpg_echo didn't work for me.I got error -ksh: shopt: not found [No such file or directory] – g4ur4v Nov 7 '12 at 19:39
up vote 7 down vote accepted

That's the behavior of POSIX and Unix conformant echo. With a Unix conformant echo, you'd write:

echo 'Check Script\c'

Best is not to use echo but printf instead which has fewer portability issues.

printf %s 'Check Script'

Note that POSIX allows -n as an extension (but with unspecified behavior). echo -e is meant to output -e\n, so in that regard, bash and zsh are not POSIX conformant.

share|improve this answer

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.