Updated: April 19, 2023

Write arguments to standard output (POSIX)


echo [-n] [string...]

Runs on:

QNX Neutrino, Mac, Microsoft Windows


Don't write a trailing newline character.
A string to be written to standard output.


The echo utility writes its arguments, followed by a newline character, to standard output. If there are no arguments, only the newline character is written.

On the target system, echo is present as:
  • a shell builtin command (see the echo command for ksh)
  • the echo utility, which is a standalone executable that can operate without the availability of the system shell
Both versions behave in a somewhat similar manner, but the ksh version supports extra options. The echo utility is included in the ${QNX_TARGET} files of your QNX SDP installation. To make sure you use the utility on the target, specify the full path you used in the buildfile when including the utility in the image (e.g., /proc/boot/echo).

On the host system, echo is present in the two forms mentioned above but also as an OS command that you can run in a command session. You can use the echo utility independently of a shell process such as ksh or an OS command session. To make sure you use the utility, specify the full path; the exact path depends on the host OS. On Windows, the path must be specified as ${QNX_HOST}\usr\bin\echo.exe in scripts but %QNX_HOST%\usr\bin\echo.exe in a command line. On Mac, it's ${QNX_HOST}/usr/bin/echo for both usages.

If you run which echo on the host, this command's output can be misleading because it will provide the path of the QNX SDP echo utility, but if you just type echo in an OS command session, it's the OS command and not the QNX SDP utility that runs.

There are differences in behavior between the OS command and the QNX SDP echo utility. The utility follows the POSIX standard in terms of supported options, meaning -n is supported, but the OS command's supported options depend on the host OS. On Windows, this command does not support -n but on Mac, it does support -n. Also on Mac, the OS command supports the extra option -e; the utility does not (on any host OS). For more information, see your host OS documentation on echo.

The echo utility supports the following escape sequences within string:

Escape Description
\a Write an alert character (the bell).
\b Write a backspace character.
\c Suppress the newline character that otherwise follows the final argument in the output. All characters following the \c in the arguments are ignored.
\f Write a formfeed character.
\n Write a newline character.
\r Write a carriage-return character.
\t Write a tab character.
\v Write a vertical tab character.
\\ Write a backslash character.
\0num Write an 8-bit value that's the ASCII character represented by the specified 1-, 2-, or 3-digit octal number num.
Note: The escape sequences listed above are extensions to POSIX. For a more versatile utility that's portable, see printf.


Echo the string Hello, Mother\nHello, Father to the standard output (note that echo appends a final trailing newline):

$ echo 'Hello, Mother\nHello, Father'
Hello, Mother
Hello, Father

Exit status:

Successful completion.
An error occurred.