KandZ – Tuts

We like to help…!

Linux CLI 51🐧 pr, lpr and lp commands

a - pr command for printing
pr command is also used to prepare file for printing
common options: -l length β†’ number of lines per page
-number β†’ columns
-w width β†’ page width -o offset β†’ left margin offset
-f use form feeds -h header β†’ use header instead the filename
ls /etc | pr -4 -w 50 | head -n 10 β†’ lists etc formatted in 4 columns and 70 chars wide and print show only the top 10
s /etc | pr -4 -w 70 -h "etc directory" | head -n 10 β†’ same as the previous and with etc directory as a header
if you want to send it to the printer just add | lpr

b - lpr command - Berkley Style
lpr command is used to send file to a printer for printing
It is part of the CUPS (Common UNIX Printing System)
CUPS is widely used on many Linux distros
common option: -r β†’ delete files after printing
-P printer β†’ specify the name of the printer -# number β†’ number of copies
lpr file1.txt file2.txt β†’ prints multiple files if you have selected default printer
lpr -P canon -# 5 file1.txt β†’ specifies a printer and print 5 copies
lpr -o media=A4 -o page-ranges=1-5 file1.txt β†’ use of option for printing

c - lp - System V Style
lp is like lpr. Both are used to send files to the printer
lp is also part of the CUPS (Common UNIX Printing System)
lp provides more advanced option than lp
common options: -d printer β†’selects printer
-n number β†’ number of copies -o landscape β†’ landscape orientation
-P pages β†’ specify list of pages 2,4,6 as example
lp file1.txt β†’ prints file1.txt when default printer is selected
lp -d cannon file1.txt β†’ specifies default printer and print file1.txt

Leave a Reply