Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)
User Commands (d - f) echo(1)
NAME
echo - Writes arguments to standard output
SYNOPSIS
echo [string ...]
DESCRIPTION
The echo command writes the string specified by the string argument to the standard output file.
The arguments are separated by spaces, and a newline character follows the last string.Useecho
to produce diagnostic messages in command files and to send data into a pipe. If there are no
arguments, echo outputs a newline character.
The echo command recognizes the following special characters:
\a Displays an alert character.
\b Displays a backspace character.
\c Suppresses the newline character. All characters following \c in the arguments are
ignored.
\f Displays a formfeed character.
\n Displays a newline character.
\r Displays a carriage-return character.
\t Displays a tab character.
\v Displays a vertical tab character.
\\ Displays a backslash character.
\number Displays an 8-bit character whose value is the 0-, 1-, 2-, or 3-digit octal number given
by the number argument. The first digit of number must be a 0 (zero).
EXAMPLES
1. To write a message to standard output, enter:
echo Please insert diskette . . .
2. To display a message containing special characters as listed in DESCRIPTION,enclose
the message in quotes, as follows:
echo "\n\n\nI’m at lunch.\nI’ll be back at 1 p.m."
This command skips three lines and displays the messages:
I’m at lunch.
I’ll be back at 1 p.m.
Note that you must enclose the message in quotation marks if it contains escape
sequences such as \n. Otherwise, the shell treats the \ (backslash) as an escape character.
The previous command line, entered without the quotation marks, results in the follow-
ing output:
nnnI’m at lunch.nI’ll be back at 1 p.m.
3. To use echo with pattern-matching characters, enter:
echo The back-up files are: *.bak
527188-004 Hewlett-Packard Company 3−23