Name

echo

Synopsis

    echo [-n] [string]

Korn shell version. Write string to standard output; if -n is specified, the output is not terminated by a newline. If no string is supplied, echo a newline.

The Korn shell’s echo, even though it is built-in to the shell, emulates the system’s version of echo. Thus, if the version found by a path search supports -n, the built-in version does too. Similarly, if the external version supports the escape sequences described below, the built-in version does too; otherwise it does not.[*] (See also echo in Chapter 2.) echo understands special escape characters, which must be quoted (or escaped with a \) to prevent interpretation by the shell:

\a

Alert (ASCII BEL).

\b

Backspace.

\c

Suppress the terminating newline (same as -n).

\f

Formfeed.

\n

Newline.

\r

Carriage return.

\t

Tab character.

\v

Vertical-tab character.

\\

Backslash.

\0 nnn

ASCII character represented by octal number nnn, where nnn is one, two, or three digits and is preceded by a 0.

[*] The situation with echo is a mess; consider using printf instead.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.