home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

echo

echo [-n ] [string ]

Echo arguments to standard output. Often used for producing prompts from shell scripts. This is the /bin/echo command. echo also exists in /usr/ucb , and as a command built into the Bourne, C, and Korn shells (see Chapter 4 and Chapter 5 ).

Although echo is conceptually the simplest of all Unix commands, using it in practice is complicated, because of portability and version differences. (Consider using printf instead.) The following sections summarize the differences.

Version Differences

/bin/echo

Does not accept the -n option. Interprets the escape sequences described next.

/usr/ucb/echo

Accepts the -n option if it's first. Does not interpret escape sequences.

Bourne shell echo

Does not accept the -n option. Interprets the escape sequences described next, except \a .

C shell echo

Accepts the -n option if it's first. Does not interpret escape sequences.

Korn shell echo

Searches $PATH and behaves like the first version of echo that it finds.

Escape Sequences

\a

Alert (ASCII BEL). (Not in /bin/sh 's echo .)

\b

Backspace.

\c

Suppress the terminating newline (same as -n ).

\f

Formfeed.

\n

Newline.

\r

Carriage return.

\t

Tab character.

\v

Vertical-tab character.

\\

Backslash.

\0 nnn

ASCII character represented by octal number nnn , where nnn is 1, 2, or 3 digits and is preceded by a 0.

Examples

echo "testing printer" | lp


echo "TITLE\nTITLE" > file ; cat doc1 doc2 >> file


echo "Warning: ringing bell \07"


Previous: Reference: du UNIX in a Nutshell: System V Edition Next: Reference: ed
Reference: du Book Index Reference: ed

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru