The first synopsis describes the traditional echo builtin command for sh(1) ksh88(1) and other legacy shells, as well as the /usr/bin/echo standalone command. The -n option is used when the termination by a new-line is not wanted. The -n option is a transition aid for legacy applications, and will be removed in a future release.
The second synopsis describes the echo builtin command for the system's standard shell, ksh(1) (ksh-93). This version is standards-compliant and as such does not support the -n option.
The other capabilities of echo described here are the same between both versions.
echo understands the following C-like escape conventions (beware of conflicts with the shell's use of the backslash character):
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''.
2 digits | Incorrect: | echo "\0337" | od -xc |
produces: |
df0a (hex)
| |
337 (ascii)
| ||
3 digits | Correct: | echo "\00337" | od -xc |
produces: |
lb37 0a00 (hex)
| |
033 7 (ascii)
|