lpr MacOS command
The lpr command on MacOS allows users to print files directly from the terminal. With this command, users can easily send documents to a printer without the need for a graphical user interface. The lpr command supports various options for specifying the printer, number of copies, print quality, and more. By mastering the lpr command, users can streamline their printing workflow and efficiently manage their printing tasks from the command line.
lpr Syntax:
Section titled “lpr Syntax:”lpr [options] [filename]
Options:
Section titled “Options:”Option | Description |
---|---|
-# | Specify the number of copies to print |
-P | Specify the printer name |
-o | Specify additional options |
-J | Set the job name for the print job |
-C | Print the file in banner format |
-Z | Compress the data before sending it to the printer |
-h | Do not wait for the job to complete before exiting |
Parameters:
Section titled “Parameters:”Parameter | Description |
---|---|
filename | The file to be printed |
lpr bash Examples:
Section titled “lpr bash Examples:”Print a File
Section titled “Print a File”lpr file.txt
Sends the file “file.txt” to the default printer to be printed.
Print Multiple Files
Section titled “Print Multiple Files”lpr file1.txt file2.txt file3.txt
Prints multiple files (“file1.txt”, “file2.txt”, and “file3.txt”) one after the other.
Print a File with Specific Printer
Section titled “Print a File with Specific Printer”lpr -P PrinterName file.txt
Directs the file “file.txt” to be printed on a specific printer named “PrinterName”.
Print a File in Black and White
Section titled “Print a File in Black and White”lpr -o ColorModel=KGray file.txt
Prints the file “file.txt” in black and white using the KGray color model.
Print a File with Double-Sided Printing
Section titled “Print a File with Double-Sided Printing”lpr -o sides=two-sided-long-edge file.txt
Prints the file “file.txt” with double-sided printing, flipping the pages along the long edge.
Print a File with Multiple Copies
Section titled “Print a File with Multiple Copies”lpr -#3 file.txt
Prints 3 copies of the file “file.txt” in a single print job.
How do I check the version of lpr in MacOS?
Section titled “How do I check the version of lpr in MacOS?”To check the version of lpr in MacOS, use the following command:
lpr --version
How do I print a file using lpr in MacOS?
Section titled “How do I print a file using lpr in MacOS?”To print a file using lpr in MacOS, execute the following command:
lpr file.txt
How do I list available printers with lpr in MacOS?
Section titled “How do I list available printers with lpr in MacOS?”To list available printers using lpr in MacOS, use the following command:
lpstat -p
How do I set the number of copies with lpr in MacOS?
Section titled “How do I set the number of copies with lpr in MacOS?”To set the number of copies using lpr in MacOS, execute the following command:
lpr -#2 file.txt
How do I cancel a print job with lpr in MacOS?
Section titled “How do I cancel a print job with lpr in MacOS?”To cancel a print job using lpr in MacOS, use the following command:
lprm <job_id>
How do I print to a specific printer with lpr in MacOS?
Section titled “How do I print to a specific printer with lpr in MacOS?”To print to a specific printer using lpr in MacOS, execute the following command:
lpr -P printer_name file.txt
How do I view print job status with lpr in MacOS?
Section titled “How do I view print job status with lpr in MacOS?”To view print job status using lpr in MacOS, use the following command:
lpq
How do I set page range for printing with lpr in MacOS?
Section titled “How do I set page range for printing with lpr in MacOS?”To set a page range for printing using lpr in MacOS, execute the following command:
lpr -P printer_name -o page-ranges=1-5 file.txt
Applications of the lpr command
Section titled “Applications of the lpr command”- Sending files to a printer for printing.
- Managing print queues.
- Specifying print options such as number of copies, page range, and print quality.
- Printing from the command line.
- Automating printing tasks using scripts or other programs.
- Checking the status of print jobs.