echo
[-n
] [string]Echo arguments to standard output. Often used for producing prompts from shell scripts. This is the /bin/echo command. echo also exists in /usr/ucb, and as a command built into the Bourne, C, and Korn shells (see Chapter 4 and Chapter 5).
Although echo is conceptually the simplest of all Unix commands, using it in practice is complicated, because of portability and version differences. (Consider using printf instead.) The following sections summarize the differences.
Does not accept the -n
option. Interprets the escape sequences described next.
Accepts the -n
option if it's first. Does not interpret escape sequences.
Does not accept the -n
option. Interprets the escape sequences described next, except \a
.
Accepts the -n
option if it's first. Does not interpret escape sequences.
Searches $PATH and behaves like the first version of echo that it finds.
\a | Alert (ASCII BEL). (Not in /bin/sh's echo.) |
\b | Backspace. |
\c | Suppress the terminating newline (same as |
\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 1, 2, or 3 digits and is preceded by a 0. |
echo "testing printer" | lp
echo "TITLE\nTITLE" > file ; cat doc1 doc2 >> file
echo "Warning: ringing bell \07"