Name

echo

Synopsis

    echo [-eEn] [string]

Bash version, built-in to the shell. Write string to standard output. (See also echo in Chapter 2.)

Options

-e

Enable interpretation of the following escape sequences, 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).

\e

ASCII Escape character.

\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 zero, one, two, or three digits and is preceded by a 0.

\ nnn

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

\x HH

ASCII character represented by hexadecimal number HH, where HH is one or two hexadecimal digits.

-E

Do not interpret escape sequences, even on systems where the default behavior of the built-in echo is to interpret them.

-n

Do not print the terminating newline.

Examples

$ echo "testing printer" | lp
    $echo "Warning: ringing bell \a"

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.