9.3.18 print command (outputs to the standard output)
Syntax
print [-n|-p|-r] [-u [num]] [--] [args]
Description
This command outputs what is specified in the arguments to the standard output. Trailing linefeeds are appended to the output.
Escape characters prefixed with \ are replaced in the output. The following table shows the escape characters that are replaced:
Escape character |
Meaning |
---|---|
\a |
Alert character (bell) |
\b |
Backspace character |
\c |
Suppress the trailing linefeed (characters after the \c are not output) |
\f |
Formfeed character (page break) |
\n |
Linefeed character |
\r |
Carriage return character |
\t |
Tab character |
\v |
Vertical tab character |
\0nnn# |
ASCII character represented by one, two, or three octal digits (0 to 7) |
\\ |
A single backslash character |
- #
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.
When the -r option is specified, escape characters are ignored.
Arguments
- -n
Specifies that trailing linefeeds are to be omitted from the output to the standard output.
- -p
Specifies that a pipe is to be used to send the output to the standard input of a background process, rather than to the standard output.
- -r
Specifies that escape characters are to be ignored.
- -u [num]
Specifies the file identifier to which the output is to be output. When no value is specified, 1 is assumed.
Specify either an output destination file identifier or p. Specifying p is equivalent to specifying the -p option.
- --
Specifies the end of the option specifications. Any options specified after this option are interpreted as part of args.
- args
Specifies the arguments (what is to be output).
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 |
Error termination |
Notes
Even if the command syntax of this regular built-in command is invalid, it does not exit the shell that is executing the command.
If a value outside the ASCII code range is specified when escape characters are expressed as ASCII character strings, the content to be output follows the character encoding specified for the terminal and unprintable characters might produce an incorrect output.
Examples
Output the character string abc with a trailing linefeed.
Contents of the job definition script
print "abc\n"
Contents of the STDOUT file of the execution job
******** JOB SCOPE STDOUT ******** Abc
Output the character string abc to the standard input of the coproc.sh background process.
coproc.sh |& print -p abc