echo Command Purpose Writes character strings to standard output. Syntax echo [ -n ] [ String ... ] Description The echo command writes character strings to standard output. Strings are separated by spaces, and a new-line character follows the last String. If no String is specified, a blank line (new- line character) is displayed. Use the echo command to produce diagnostic messages in command files and to send data into a pipe. The echo command recognizes the following escape conventions: \b Displays a backspace character. \c Suppresses the new-line character. \f Displays a form-feed character. \n Displays a new-line 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 ASCII value is the 1-, 2-, or 3-digit octal number Number. The first digit of Number must be a 0. Note: The bsh, csh, and ksh commands each contain a built-in echo subcommand. The echo command and the echo subcommand do not necessarily work the same way. For information on these subcom- mands, see the bsh, csh, and ksh commands. Flags -n No new-line character is added to the output. Exit Status This command returns the following exit values: 0 Successful completion. >0 An error occurred. Examples 1. To write a message to standard output, enter: echo Please insert diskette . . . 2. To display a message containing special characters, enter: 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 put the message in quotation marks if it contains escape sequences such as \Number. Otherwise, the shell inter- prets the \ (backslash) as a metacharacter and treats the \ differently. 3. To use the echo command with pattern-matching characters, enter: echo The back-up files are: *.bak This usage 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, enter: echo Remember to set the shell search path to $PATH. >>notes This usage 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, enter: echo Error: file already exists. >&2 Use this command in shell procedures to write error messages. If the >&2 is omitted, the message is written to the standard out- put. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/echo Contains the echo command. Related Information The Command Input and Output Redirection section in Commands, Processes, and Virtual Terminals Overview in AIX Version 3.2 Sys- tem User's Guide: Base and Devices describes how the operating system processes input and output and how to use the redirect and pipe symbols. The bsh command, csh command, ksh command.