Dave Taylor's May 2014 Work the Shell Column

Glad to know you’re reading my columns, Torben! Truth be told, I develop on a variety of platforms, not just Linux, so while what you say might well be true, it’s not true across all *nix systems. For example, on my Mac OS X system:

$ cat test.sh
echo -n testing
exit 0
$ sh test.sh
-n testing

Disappointing. It’s like the 1980s all over again. Now where’s my polyester? — DaveT

I always read Dave Taylor's Work the Shell column end-to-end, despite being an old hand at scripting and what-not. It is always possible to learn from other people, no matter how many years you have in the business.

In the May 2014 column, Dave mentions that bash does not understand the -n option for the built-in echo command, which I find strange, as it works fine for me (and has worked as far back as I can remember — which makes it at least a couple of days ago).

I do recollect fondly of the days of yore when we had to keep track of two distinct flavours of echo: the BSD version where you told echo to hold its breath (i.e., no newline at the end) with a -n option (like echo -n "Hold your breath") and the Sys V version where you whispered at the end of the sentence for it to hold its breath with \c (like echo "Hold your breath\c"). bash still holds the capability to understand the Sys V behaviour with the -e option (like echo -e "Hold your breath\c"), just to make life more exciting.

But, to make a long story a little longer: To the best of my knowledge, the -n option should work more or less everywhere in Linux, including with the bash built-in version of echo.

Best regards