echo

display arguments 

Command, KornShell Built-in


SYNOPSIS

echo argument...

echo [-Een] argument...


DESCRIPTION

echo writes its arguments to the standard output. Normally, echo accepts and interprets the following C-style escape sequences:

\a 
bell
\b 
backspace
\c 
removes any following characters including \n and \r
\e 
escape character
\E 
escape character
\f 
formfeed
\n 
newline
\r 
carriage return
\t 
horizontal tab
\v 
vertical tab
\xHH 
the character whose hexadecimal value is HH (one or two hex digits).
\0num 
the byte with the numeric value specified by the zero to three digit octal num
\\ 
backslash

Note:

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 names. To display such strings properly, you should use print -r instead of echo.

Options

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.

-E 

Disables escape sequences. When disabled, escape sequences are treated as normal text with no special meaning.

-e 

Enables escape sequences.

-n 

Suppresses the trailing newline that is normally appended to each line of output.


EXAMPLES

One use of echo is to expand file names on the command line, as in:

echo *.[ch]

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

ENVIRONMENT VARIABLES

TK_ECHO_DEFAULT_NO_ESCAPE_SEQUENCES 

When set to a non-zero value, echo, by default, treats escape sequences as normal text with no special meanings.

TK_ECHO_USE_BASH_BEHAVIOR 

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.


DIAGNOSTICS

echo always returns the status value:

0 

Successful completion.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. UNIX System V. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. Windows Server 2025.

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; the -n option is equivalent to \c embedded in an argument.


NOTE

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:


AVAILABILITY

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 Windchill Requirements and Validation


SEE ALSO

Commands:
print, sh


PTC MKS Toolkit 10.5 Documentation Build 40.