Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ echo(1) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

csh(1)

ksh(1)

sh(1)

ascii(5)

meta-ascii(5)

echo(1)                                                             echo(1)

NAME
     echo - echo command-line arguments

SYNOPSIS
     echo [argument ...]

DESCRIPTION
     The utility echo writes its arguments to standard output and ter-
     minates. The following takes place before the output is generated:

     1. As with every other command, the shell interprets the command line
        arguments and then passes the edited arguments to echo [see sh(1)].
        The argument separators recognized by the shell are blanks and
        tabs.

     2. echo interprets any remaining special characters that control out-
        put (see description of argument).

     3. echo displays processed arguments as follows:

        -  Each argument is separated from the next by a blank even if you
           have entered more than one argument separator between individual
           arguments in the call.

        -  A newline character is output at the end of the last argument.

     You can use echo to

     ⊕  examine values of shell variables,

     ⊕  generate messages in shell scripts and thus test how they function,

     ⊕  test how the shell interprets a command call without the command
        being executed,

     ⊕  redirect data to a pipe and test how the pipe processes this input.

     Besides the shell built-in echo, there is also a command called
     /usr/bin/echo. The shell generates a new process to execute
     /usr/bin/echo. Otherwise, /usr/bin/echo operates in the same way as
     echo.

OPERANDS
     argument
          Any string delimited by blanks or tabs. The last argument is ter-
          minated by means of a command separator.

          argument not specified: echo produces only a blank line.







Page 1                       Reliant UNIX 5.44                Printed 11/98

echo(1)                                                             echo(1)

          You may specify any number of arguments, provided they are sepa-
          rated by at least one tab or blank character.

          As with any other command, this string is also initially inter-
          preted by the shell:

          -  If the string contains an asterisk, question mark, or [...],
             the shell replaces this string by all suitable file names in
             the current directory. If no suitable file name is found, the
             shell passes the string on to echo unaltered.

          -  'string'

             All shell metacharacters are escaped by the single quotes. The
             shell passes the string as an argument to echo without the
             quotes. All blanks, tabs and newline characters entered within
             single quotes are retained.

          -  `string`

             The shell executes string as a Reliant UNIX command and passes
             the output of this command to echo. Characters assigned to the
             environment variable IFS are interpreted by the shell in the
             output as argument delimiters. The default characters assigned
             to IFS are the blank, tab or newline characters.

          -  "string"

             The double quotes escape all shell metacharacters except for
             the backslash \, backquotes ` ...` and the dollar sign $. The
             shell passes the processed string to echo as an argument. All
             blanks, tabs, and newline characters within the double quotes
             are retained.

          The shell built-in echo also interprets the control characters
          described below. Since the backslash has a special meaning for
          the shell, it must be escaped:

          -  by preceding it with another backslash \

             This also applies if the argument containing this control
             character is enclosed within double quotes.

          -  by single quotes '...'

             If the argument containing this control character is enclosed
             within single quotes, the backslash need not be escaped again.







Page 2                       Reliant UNIX 5.44                Printed 11/98

echo(1)                                                             echo(1)

          Example:
          ________________________
         | Input       |  Output |
         |_____________|_________|
         | hello\\bi   |  helli  |
         |_____________|_________|
         | hello'\'bi  |  helli  |
         |_____________|_________|
         | 'hello\bi'  |  helli  |
         |_____________|_________|
         | "hello\\bi" |  helli  |
         |_____________|_________|

          The following control characters influence the output of echo,
          provided the backslash has been appropriately escaped:

          \a    (a - alert) warning, bell; a beep is usually heard when
                output appears on the screen, the character has no effect
                for printer output.

                \a corresponds to CTRL-G

                \a is only interpreted by the Korn shell ksh.

          \b    (backspace) echo sets the cursor position one column to the
                left. Any character that is entered after the control char-
                acter will overwrite the character at which the cursor is
                located.

                \b corresponds to BACKSPACE or CTRL-H

          \c    echo prints the arguments entered up to this control char-
                acter, omitting the newline and ignoring the remaining
                arguments.

          \f    (form feed) This control character is not converted if the
                output is written to the terminal.

                If the output from echo is sent to a printer, for example,
                all arguments entered after this control character will be
                written on the next page.

                \f corresponds to CTRL-L

          \n    (newline) All arguments that follow the newline character
                are written in the next line.

                \n corresponds to RETURN or CTRL-J






Page 3                       Reliant UNIX 5.44                Printed 11/98

echo(1)                                                             echo(1)

          \r    (carriage return) echo sets the cursor position to column 1
                of the current line. Characters entered after this control
                character overwrite any characters previously printed by
                echo in the columns of the current line.

                \r corresponds to CTRL-M

          \t    Control character for tab; echo moves the cursor to the
                next tab stop. Characters entered after \t are written by
                echo from this column onward.

                The setting of tab stops depends on the data terminal that
                is used. On a Siemens Nixdorf 97801 terminal, tab stops are
                set at the following columns:

                1   9   17   25   33   41   49   57   65   73   79

                \t corresponds to TAB or CTRL-I

          \v    Control character for vertical tab; echo sets the cursor to
                the next vertical tab stop. Vertical tabs are not usually
                set (depending on the type of terminal used).

                \v corresponds to CTRL-K

          \\    Write a backslash character (\).

          \0n   n must be a one to three-digit octal number. echo outputs
                the corresponding character [see ascii(5) and
                meta-ascii(5)]. You can use this option to generate charac-
                ters with a machine code higher than 7f (hexadecimal), for
                example, even if you do not have an 8-bit terminal.

                Non-printing characters are represented by a smudge charac-
                ter (depending on the type of terminal used).

                Caution:

                If a character in octal notation is to be followed by an
                additional digit that is not part of the octal number, you
                must use the full three-digit form of the octal number.













Page 4                       Reliant UNIX 5.44                Printed 11/98

echo(1)                                                             echo(1)

                Example:
                _______________________________________________
               | Command                | Result              |
               |________________________|_____________________|
               |                        | 0adf        (hex)   |
               | echo '\0337' | od -xc  |_____________________|
               |                        | 337 \n      (ascii) |
               |________________________|_____________________|
               |                        | 371b  000a  (hex)   |
               | echo '\00337' | od -xc |_____________________|
               |                        | 033  7  \n  (ascii) |
               |________________________|_____________________|

     If control characters of the above type are to be interpreted by nei-
     ther the shell nor echo, they must be entered as follows:
     ____________________________
    | Input  |  Output          |
    |________|__________________|
    | \\     |  the backslash \ |
    |________|__________________|
    | \\\\b  |  the string \b   |
    |________|__________________|
    | '\\b'  |  the string \b   |
    |________|__________________|
    | "\\\b" |  the string \b   |
    |________|__________________|

     The above example applies to the remaining strings as well.

LOCALE
     The LCMESSAGES environment variable governs the language in which
     message texts are displayed. If LCMESSAGES is undefined or is defined
     as the null string, it defaults to the value of LANG. If LANG is like-
     wise undefined or null, the system acts as if it were not internation-
     alized.



















Page 5                       Reliant UNIX 5.44                Printed 11/98

echo(1)                                                             echo(1)

EXAMPLES
     Example 1

     The following interactive session will demonstrate when blanks, tabs
     and newline characters are retained:

     $ echo Today is         Monday.
     Today is Monday.

     In this case echo receives three arguments and returns them with one
     blank between each.

     $ echo "Today is         Monday."
     Today is         Monday.

     All blanks entered within the double quotes are retained.

     $ echo `ls p*`
     pers pp ppp probe punch pwd pwddr
     $ echo "`ls p*`"
     pers
     pp
     ppp
     probe
     punch
     pwd
     pwddr

     Without double quotes, the shell removes all argument separators
     (except for one blank) from the output of the ls command and passes
     the output on to echo. The double quotes cause all blanks, tabs, and
     newline characters to be retained.

     Example 2

     User anna wants to know what value is assigned to the HOME variable:

     $ echo $HOME
     /home/anna

     Example 3

     The following line in a shell script will cause an error message to be
     written on standard error:

     echo File $1 not found >&2








Page 6                       Reliant UNIX 5.44                Printed 11/98

echo(1)                                                             echo(1)

     Example 4

     The following line in a shell script will produce an acoustic signal
     before the error message:

     echo \\07File $1 not found >&2

     Example 5

     A string constant is to be placed before the output of the date com-
     mand:

     $ echo "Today's date and time:  \\c"; date
     Today's date and time:  Wed Mar  8 17:22:05 EST 1991

     The control character \c prevents echo from interpreting the newline.
     The backslash must be escaped despite the double quotes.

NOTES
     echo exists both as an external command (/usr/bin/echo) and as a
     built-in shell command, both in the Korn shell ksh(1) as well as in
     the Bourne shell sh(1). The shell generates a new process to execute
     /usr/bin/echo.

     Some differences in behavior may occur when using echo, depending on
     which shell is being used. The possible differences are not described
     specifically.

     The external /usr/bin/echo command recognizes the -n option which
     suppresses a line feed in output [similar to the BSD /usr/ucb/echo
     command, see echo(1-ucb)].

SEE ALSO
     csh(1), ksh(1), sh(1), ascii(5), meta-ascii(5).




















Page 7                       Reliant UNIX 5.44                Printed 11/98

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