echo(1)								      echo(1)



NAME

  echo - Writes its arguments to standard output

SYNOPSIS

  Current Syntax (XPG4 conformant)


  echo [string]

  Obsolescent Syntax (not XPG4 conformant)


  echo [-n] [string]

DESCRIPTION

  The echo command writes the specified string to standard output.

  The echo command can operate in one of two modes: XPG4 conformant and not
  XPG4 conformant. The default mode is not XPG4 conformant. The echo command
  operates in XPG4 mode if the variable CMD_ENV is defined in your environ-
  ment. In XPG4 mode, any -n operand is treated as a string rather than as an
  option.  The arguments are separated by spaces and a newline character fol-
  lows the last string.	 Use the echo command to produce diagnostic messages
  in command files and to send data into a pipe.  If there are no arguments,
  the echo command outputs a newline character.

  The echo command described here is the program /usr/bin/echo.	 Both csh and
  sh shells ontain built-in echo subcommands, which do not necessarily work
  in the same way as the /usr/bin/echo command.

  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 1-, 2- or 3-digit octal
      number, number.  The first digit of number must be a 0 (zero).


FLAGS

  -n No newline is added to the output.

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
       Note that you must enclose the message in quotation marks if it con-
       tains escape sequences such as \n.  Otherwise, the shell treats the
       backslash (\) as an escape character.  The previous command example,
       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.

  Future Directions

  Future releases will provide the XPG4 conformant behavior as the default
  behavior. The -n flag is being phased out of use. See the printf reference
  page for use in portable applications.

RELATED INFORMATION

  Commands: csh(1), ksh(1), sh(1).