ECHO(1,C) AIX Commands Reference ECHO(1,C)
-------------------------------------------------------------------------------
echo
PURPOSE
Writes its arguments to standard output.
SYNTAX
+------+
echo ---| |--- string ---|
+- -n -+ ^ |
+----------+
DESCRIPTION
Note: The following description applies to /bin/echo and the sh built-in echo
command. See page csh-15 for a description of the csh built-in echo
command.
The echo command writes its arguments to standard output. The strings are
separated by blanks and a new-line character follows the last string. Use echo
to produce diagnostic messages in command files and to send data into a pipe.
The echo command recognizes the following escape conventions:
\b Display a backspace character.
\c Suppress the new-line character. Use as last option on
command line; it ignores all characters after this
option.
\f Display a form-feed character.
\n Display a new-line character.
\r Display a carriage return character.
\t Display a tab character.
\\ Display a backslash character.
\num Display an 8-bit character, whose ASCII value is the 1-,
2- or 3-digit octal number num. The first digit of num
must be a zero.
FLAG
Processed November 8, 1990 ECHO(1,C) 1
ECHO(1,C) AIX Commands Reference ECHO(1,C)
-n No newline is added to the output.
EXAMPLES
1. To write a message to standard output:
echo Please insert diskette . . .
2. To display a message containing special characters:
echo "\n\n\nI'm at lunch.\nI'll be back at 1:00."
This skips three lines and displays the message:
I'm at lunch.
I'll be back at 1:00.
Note: You must quote the message if it contains escape sequences like
"\n". Otherwise, the shell treats the "\" specially. See page
sh-5 for details about quoting.
3. To use echo with pattern-matching characters:
echo The back-up files are: *.bak
This displays the message "The back-up files are:" followed by the file
names in the current directory ending with ".bak".
4. To add a single line of text to a file:
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 shell variable PATH.
5. To write a message to the standard error output:
echo Error: file already exists. >&2
Use this in shell procedures to write error messages. If the ">&2" is
omitted, the message is written to the standard output. For details about
this type of file redirection, see "Input and Output Redirection Using File
Descriptors."
RELATED INFORMATION
See the following commands: "csh," "sh, Rsh" and "dspmsg."
Processed November 8, 1990 ECHO(1,C) 2