The echo command
is useful for producing diagnostics in command files,
for sending known data into a pipe,
and for displaying the contents of environment variables.
The command
writes its arguments, separated by blanks and terminated by
a new-line, on the standard output.
The -n option is used when the termination by a new-line is not wanted.
The -n option is a transition aid for BSD applications,
and will be removed in a future release.
echo
understands the following C-like escape conventions
(beware of conflicts with the shell's use of the backslash character):
\a
alert
\b
backspace
\c
print line without new-line
\f
form-feed
\n
new-line
\r
carriage return
\t
tab
\v
vertical tab
\\
backslash
\0n
where
n
is the 1-, 2-, or 3-digit octal encoding of an 8-bit character.
Each byte of multibyte characters should be preceded by
backslash (\).
The echo command processes supplementary code set characters
according to the locale specified in the LC_CTYPE
environment variable
(see LANG on
environ(5)).
When representing an 8-bit character by using the escape convention
\0n,
the n must be preceded by the digit zero (0).
For example, typing:
echo ´WARNING:\07´
displays the phrase WARNING:
and sounds the bell on your terminal.
The use of single (or double) quotes
(or two backslashes) is required to protect the ``\''
that precedes the ``07''.
Following the ``\0'', up to three digits are used in constructing
the octal output character.
If, following the \0n, you
want to echo additional digits that are not part of the
octal representation, you must use the full 3-digit n.
For example, if you want to echo ``ESC 7''
you must use the three digits ``033'' rather than just the two digits ``33''
after the ``\0''.