print — Return arguments from the shell
Format
print [–npRrs] [–u[descriptor]] [argument …]
Description
Calling print without options or with only the – option displays each argument to the standard output using the same escape conventions as echo. In this case, print and echo work the same way; see echo.
Options
The options accepted by print increase
its utility beyond that of echo.
- –n
- Does not automatically add a new line to the end of the output.
- –p
- Sends output to a coprocess.
- –R
- Is similar to –r, except that print treats all subsequent options (except –n) as arguments rather than as options.
- –r
- Ignores escape conventions.
- –s
- Appends the output to the command history file rather than sending it to standard output.
- –u[descriptor]
- Redirects the output to the file corresponding to the single digit file descriptor. The default file descriptor is 1.
Usage notes
print is a built-in shell command.
Localization
print uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_MESSAGES
- NLSPATH
See Localization for more information.
Exit values
- 0
- Successful completion
- 1
- Failure due to any of the following:
- Incorrect descriptor specified with –u
- Nonexistent coprocess
- 2
- Failure due to an incorrect command-line option
Messages
Possible error messages include:
- Cannot print on file descriptor …
- You tried to print on a file descriptor that was not opened for writing.
- History not available
- You specified the –s option to write into a history file, but you are not now using a history file.
Portability
print is an extension to POSIX.2 and XPG.
Related information
echo, fc, read, sh