The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


lp - send files to a printer


lp [-c][-d dest][-n copies][-msw][-o option]... [-t title]


The lp utility copies the input files to an output destination in an unspecified manner. The default output destination should be to a hardcopy device, such as a printer or microfilm recorder, that produces non-volatile, human-readable documents. If such a device is not available to the application, or if the system provides no such device, the lp utility will exit with a non-zero exit status.

The actual writing to the output device may occur some time after the lp utility successfully exits. During the portion of the writing that corresponds to each input file, the implementation guarantees exclusive access to the device.

The lp utility associates a unique request ID with each request.

Normally, a banner page is produced to separate and identify each print job. This page may be suppressed by implementation-dependent conditions, such as an operator command or one of the -o option values.


The lp utility supports the XBD specification, Utility Syntax Guidelines  .

The following options are supported:

Exit only after further access to any of the input files is no longer required. The application can then safely delete or modify the files without affecting the output operation. Normally, files will not be copied, but will be linked whenever possible. If the -c option is not given, then the user should be careful not to remove any of the files before the request has been printed in its entirety. It should also be noted that in the absence of the -c option, any changes made to the named files after the request is made but before it is printed will be reflected in the printed output. On some systems, -c may be on by default.
-d dest
Specify a string that names the destination (dest). If dest is a printer, the request will be printed only on that specific printer. If dest is a class of printers, the request will be printed on the first available printer that is a member of the class. Under certain conditions (printer unavailability, file space limitation, and so on), requests for specific destinations need not be accepted; see lpstat. Destination names vary between systems; see lpstat. If -d is not specified, and neither the LPDEST nor PRINTER environment variable is set, an unspecified destination is used. The -d dest option takes precedence over LPDEST , which in turn takes precedence over PRINTER . Results are undefined when dest contains a value that is not a valid destination name.
Send mail (see mailx) after the files have been printed. By default, no mail is sent upon normal completion of the print request.
-n copies
Write copies number of copies of the files, where copies is a positive decimal integer. The methods for producing multiple copies and for arranging the multiple copies when multiple file operands are used are unspecified, except that each file will be output as an integral whole, not interleaved with portions of other files.
-o option
Specify printer-dependent or class-dependent options. Several such options may be collected by specifying the -o option more than once.
Suppress messages from lp such as "request id is ...".
-t title
Write title on the banner page of the output.
Write a message on the user's terminal after the files have been printed. If the user is not logged in, then mail will be sent instead.


The following operand is supported:
A pathname of a file to be output. If no file operands are specified, or if a file operand is "-", the standard input will be used. If a file operand is used, but the -c option is not specified, the process performing the writing to the output device may have user and group permissions that differ from that of the process invoking lp.


The standard input will be used only if no file operands are specified, or if a file operand is "-". See the INPUT FILES section.


The input files must be text files.


The following environment variables affect the execution of lp:
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
If set to a non-empty string value, override the values of all the other internationalisation variables.
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output.
Determine the format and contents of date and time strings displayed in the lp banner page, if any.
Determine the destination. If the LPDEST environment variable is not set, the PRINTER environment variable will be used. The -d dest option takes precedence over LPDEST . Results are undefined when -d is not specified and LPDEST contains a value that is not a valid destination name.
Determine the location of message catalogues for the processing of LC_MESSAGES .
Determine the output device or destination. If the LPDEST and PRINTER environment variables are not set, an unspecified output device is used. The -d dest option and the LPDEST environment variable takes precedence over PRINTER . Results are undefined when -d is not specified, LPDEST is unset, and PRINTER contains a value that is not a valid device or destination name.




The lp utility writes a request ID to the standard output, unless -s is specified. The format of the message is unspecified. This request ID can be used later to cancel (see cancel) or find the status (see lpstat) of the request.


Used only for diagnostic messages.






The following exit values are returned:
All input files were processed successfully.
No output device was available, or an error occurred.




The pr and fold utilities can be used to achieve reasonable formatting for the implementation's default page size.

A portable application can use one of the file operands only with the -c option or if the file is publicly readable and guaranteed to be available at the time of printing. This is because the standard gives the implementation the freedom to queue up the request for printing at some later time by a different process that might not be able to access the file.


  1. To print file file:
    lp -c file

  2. To print multiple files with headers:
    pr file1 file2 | lp




lpstat, mailx.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]