If you were on a POSIX certified platform with UNIX branding, echo
did handle \c
by default.
This applies to Solaris, AIX, HP-UX and Apple.
Apple even uses bash
to support this echo behavior, but you need a specific compile option to make bash
compliant by default. This compile option for bash
is used for MacOS and for Solaris. So peole may be confused when they realise that bash
behaves different on a POSIX certified platform,
Remember: GNU
reads GNU is not UNIX.... many GNU tools are not POSIX compliant or not POSIX compliant by default. So be careful when you are not on a certified platform.
BTW: You may get the POSIX branding for small embedded platforms even when you do not support echo \c
, but for a UNIX
branding, you need to support all XSI
extensions to POSIX. Linux does not support most of the XSI
extensions. Many Linux distros e.g. use dash
as the default shell and dash
id definitely not compliant, e.g. because it does not support multi byte characters.
type -a echo
. Usually, you will have a shell built-in calledecho
provided by your shell in addition to/usr/bin/echo
which would have the flags you are looking for. The shell built-in usually supersedes the installed program.-n
and requires-e
to regognise\c
$ /bin/echo --version
echo (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
echo
? Since you are mentioning GNU: notes about POSIX compatibility can be found ininfo coreutils echo
; they are not included inman echo
.If the ‘POSIXLY_CORRECT’ environment variable is set,
... I think that answers my question.printf
instead ofecho
.