January 2004
Intermediate to advanced
368 pages
7h 25m
English
While most modern Unix and Linux implementations have a version of the echo command that knows that the -n flag should cause the program to suppress the trailing newline, not all implementations work that way. Some use \c as a special embedded character to defeat the default behavior, and others simply insist on including the trailing newline regardless.
Figuring out whether your particular echo is well implemented is easy: Simply type in the following on the command line and see what happens:
$ echo -n "The rain in Spain"; echo " falls mainly on the Plain"
If your echo works with the -n flag, you'll see:
The rain in Spain falls mainly on the Plain
If it doesn't, you'll see this:
-n The rain in ...
Read now
Unlock full access