Bash Script Echo -n

bashecho

I am writing a bash script, and I want to echo a string, but without a newline automatically added to the end. Reading the man page it says the flag is -n.

The problem is, when I do:

echo -n "My string is here"

The output in the bash script is:

-n My string is here

Any idea why the -n flag is being outputted instead of processed.

Best Answer

Check the shell you are using with:

echo $0

If it is /bin/sh, change to /bin/bash with chsh and try again.

http://hints.macworld.com/article.php?story=20071106192548833