Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


echo command (outputs what is specified in arguments to the standard output)

Organization of this page

Format

echo  [-n] [-e|-E]  [args ...]

Description

This command outputs what is specified in arguments to the standard output.

During the output processing, escape characters that begin with a backslash (\) are replaced. The following table shows the escape characters that are replaced:

Escape character

Meaning

\a

Alert character (bell)

\b

Backspace character

\c

Suppress trailing linefeed (characters after \c are not output)

\f

Formfeed character (page break)

\n

Linefeed character

\r

Carriage return character

\t

Tab character

\v

Vertical tab character

\0nnn#1

ASCII character represented by one, two, or three octal digits (0 to 7)

\xnn#2

ASCII character represented by one or two hexadecimal digits (0 to 9, a to f, A to F)

\\

A single backslash character

#1

If a specified ASCII character consists of one or two digits and two or one leading zeros, respectively, are added to make it three digits, the ASCII character will still be treated as consisting of only one or two digits. For example, the following three specifications are all interpreted as being the same, in which case the alert character (bell) is output three times:

echo -e "\07"

echo -e "\007"

echo -e "\0007"

#2

Enabled only when YES is specified in the ESCAPE_SEQ_ECHO_HEX environment setting parameter. For details about the ESCAPE_SEQ_ECHO_HEX parameter, see ESCAPE_SEQ_ECHO_HEX parameter (specifies whether ASCII code characters in hexadecimal notation are to be interpreted as escape characters) in 7. Parameters Specified in the Environment Files.

If a specified ASCII character consists of one digit and a leading zero is added to make it two digits, the ASCII character will still be treated as consisting of only one digit. For example, the following two specifications are interpreted as being the same, in which case the linefeed character is output twice:

echo -e "\xA"

echo -e "\x0A"

If you want to replace an escape character, enclose the -e option argument in single or double quotation marks (' or "), as in Example 2 below. The following examples show how escape characters are interpreted depending on whether quotation marks are used and whether the -e or -E option is specified.

  1. In this example, ta is output to the standard output:

    echo -e \ta
  2. In this example, tab-charactera is output to the standard output:

    echo -e "\ta"
  3. In this example, ta is output to the standard output:

    echo -E \ta
  4. In this example, \ta is output to the standard output:

    echo -E "\ta"

Options specified for commands and interpretation of arguments

If the characters specified as the arguments to the echo command are all valid option characters, they are interpreted as options. For example, because the letters in eEn are all valid option characters, they are interpreted as options in the following example:

echo -eEn

However, if even one character is not a valid option character, the characters are interpreted as an args value. In the next example, because a is not a valid option character, -eEna is interpreted as an args value, which will be sent to the standard output.

echo -eEna

Finally, when an argument is enclosed in quotation marks, the entire enclosed character string is interpreted as a single argument. In the next example, because the space is not a valid option character, -e a is interpreted as an args value, which will be sent to the standard output.

echo "-e a"
Interpretation of escape characters (-e and -E options)

Escape characters are interpreted as follows, depending on the specification of the -e and -E options:

Arguments

-n

Specifies that trailing linefeeds are to be omitted from the output to the standard output.

-e

Specifies that escape characters are to be interpreted. The escape characters to be interpreted are determined by the specification of the ESCAPE_SEQ_ECHO_HEX environment setting parameter. If you want escape characters to be interpreted, enclose them in single or double quotation marks (' or ").

-E

Specifies that escape characters are not to be interpreted.

args

Specifies the arguments (what it is that is to be output).

Return codes

Return code

Meaning

0

Normal termination

1

Error termination

Notes

Usage example