Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

csh(1)

ksh(1)

sh(1)

echo(1)  —  Commands

OSF

NAME

echo − Writes its arguments to standard output

SYNOPSIS

echo [string ...]

The echo command writes the specified string to standard output. 

DESCRIPTION

The arguments are separated by spaces and a newline character 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 /bin/echo.  Both csh and sh contain built-in echo subcommands, which do not necessarily work in the same way as the /bin/echo command. 

The echo command recognizes the following special characters:

\bDisplays a backspace character. 

\cSuppresses the newline character. 

\fDisplays a formfeed character. 

\nDisplays a newline character. 

\rDisplays a carriage-return character. 

\tDisplays a tab character. 

\vDisplays a vertical tab. 

\\Displays a backslash character. 

\numberDisplays 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.  Otherwise, 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 file 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). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026