echo does not support -n flag
The -n flag prevents echo from printing a newline
Updated by Rich Lowe almost 10 years ago
One of the classic differences between UCB and SYSV echo(1). UCB echo uses -n, SYSV has a "\c" escape that prevents the trailing newline and accepts no flags (so its arguments, whatever they may be, are echoed literally). Use /usr/ucb/echo -n, /usr/gnu/bin/echo -n, or echo "foo\c" as a workaround.
At this point, I wouldn't be shocked to find we were the last hold-out of SYSV-style echo(1), though, as far as concerns for compatibility go.
Updated by Roland Mainz almost 10 years ago
Technically NO new application should ever use "echo".
Please please please use "printf" (e.g. /usr/bin/printf ... and bash+ksh93 have "printf" builtin shell utilties) for this purpose - it was invented by the POSIX/SUS people to end the neverending horror of "echo".
Updated by Garrett D'Amore almost 10 years ago
- Status changed from New to Rejected
Actually, supporting -n, while at first sounding like a good idea, would explicitly violate the POSIX standards:
So, we can't add
n - as already indicated, this is a historic SYSV vs. BSD difference, and we won't be changing it. The "portable" way is to do printf(1) - of course many scripts have special logic to test for echo -n vs. echo "\c".