echo writes its arguments to the standard output. Normally, echo accepts and interprets the following C-style escape sequences:
- removes any following characters including \n and \r
- escape character
- escape character
- carriage return
- horizontal tab
- vertical tab
- the character whose hexadecimal value is HH (one or two hex digits).
- the byte with the numeric value specified by the zero to three digit octal num
Both \xHH and \0num treat the associated numeric value as though it is in the OEM code page.
echo follows the final argument with a newline unless it finds \c in the arguments. Arguments are subject to standard argument manipulation.
Because echo interprets backslashes as the beginning of
an escape sequence and path names can contain backslashes,
echo can produce unusual results when attempting to
display the value of PATH or any string may contain path
To display such strings properly, you should use print
These options are only available when using the built-in version of echo with the shell in bash mode or when using either version of echo with the TK_ECHO_USE_BASH_BEHAVIOR environment variable set to a non-zero value. Otherwise, they are interpreted as text.
Disables escape sequences. When disabled, escape sequences are treated as normal text with no special meaning.
Enables escape sequences.
Suppresses the trailing newline that is normally appended to each line of output.
One use of echo is to expand file names on the command line, as in:
This displays the names of all files with names ending in .c or .h, typically C source and header files. echo displays the names on a single line. If there are no file names in the current directory that end in .c or .h, echo simply displays the string *.[ch].
echo is also handy for passing small amounts of input to other filters:
echo 'this is\nreal handy' | banner
When set to a non-zero value, echo, by default, treats escape sequences as normal text with no special meanings.
When set to a non-zero value, echo accepts the options described in the Options section. When not set or set to zero, these options are only accepted if you are using the built-in version of echo and the shell is in bash mode.
echo always returns the status value:
POSIX.2. x/OPEN Portability Guide 4.0. UNIX System V. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.
The POSIX.2 standard does not include the escape sequences, so a strictly conforming application cannot use them. printf is suggested as a replacement.
On older UNIX systems, the backslash escape sequences are not available;
echo is provided as both an external utility and a built-in MKS KornShell utility. The echo command provided with PTC MKS Toolkit should not be confused with the echo command provided with Windows.
To gain access to this command on Windows systems, outside the MKS KornShell, do one of the following:
- call echo with its full path name (usually, $ROOTDIR/mksnt/echo.exe)
- copy echo.exe to another file name to avoid a clash with the built-in command
PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC MKS Toolkit 10.1 patch 1 Documentation Build 2.