NAME
echo - Writes its arguments to standard output
SYNOPSIS
echo [-n] [string ...]
The echo command writes the specified string to standard
output.
FLAGS
-n No newline is added to the output.
DESCRIPTION
The arguments are separated by spaces and a newline charac-
ter follows the last string. Use echo to produce diagnostic
messages in command files and to send data into a pipe.
The echo command described here is the program
/usr/bin/echo. Both csh and sh contain built-in echo sub-
commands, which do not necessarily work in the same way as
the /usr/bin/echo command.
The echo command recognizes the following special charac-
ters:
\b Displays a backspace character.
\c Suppresses the newline character.
\f Displays a formfeed character.
\n Displays a newline character.
\r Displays a carriage-return character.
\t Displays a tab character.
\\ Displays a backslash character.
\number
Displays an 8-bit character whose value is the 1-, 2- or
3-digit octal number, number. 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 skips three lines and displays the message:
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. Oth-
erwise, the shell treats the \ (backslash) as an escape
character. The above command, entered without the
quotes, results in the following 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
This displays the message The back-up files are: and
then displays the filenames in the current directory
ending with .bak.
4. To add a single line of text to a file, enter:
echo Remember to set the shell search path to $PATH. >>notes
This adds the message to the end of the file notes
after the shell substitutes the value of the PATH shell
variable.
5. To write a message to the standard error output (sh
only), enter:
echo Error: file already exists. >&2
Use this in shell procedures to write error messages.
If the >&2 is omitted, then the message is written to
the standard output.
RELATED INFORMATION
Commands: csh(1), ksh(1), sh(1).
Acknowledgement and Disclaimer