lp - macOS


Overview

The lp command in macOS is used for sending print jobs to a designated printer or a queue of print jobs. It provides an interface for managing print requests and interacting with the macOS printing system.

Syntax

lp [options] [filename] [username] [destination]

Options/Flags

  • -c: Copies the specified number of copies.
  • -d: Specifies the destination printer or queue.
  • -l: Lists available printers and their options.
  • -m: Mails the output of the command.
  • -o: Sets printing options (e.g., page range, orientation).
  • -p: Pauses the specified print job.
  • -r: Restarts the specified print job.
  • -s: Submits the print job without notifying.
  • -D: Enables debug mode.

Examples

Printing a File

lp -d printer_name filename

Printing Multiple Copies

lp -c 3 filename

Printing a Specific Page Range

lp -o page-ranges=1-5 filename

Listing Available Printers

lp -l

Common Issues

  • No printers found: Ensure that a printer is connected and turned on. Check the printer’s connection status in System Preferences.
  • Print job stuck in queue: The printer might be offline or encountering technical issues. Restart the printer and try again. You can also try deleting the print job from the queue using the lp command with the -c option.

Integration

lp can be integrated with other macOS commands to automate print tasks. For example:

find . -name "*.pdf" | lp

This command will find all PDF files in the current directory and print them.

  • lprm: Removes a print job from the queue.
  • lpr: Prints a file without entering interactive mode.
  • Printer Utility: macOS application for printer management and configuration.