Printing files
Before we get into printing, I highly recommend reading a little on printing history in The Linux Command Line.
I rarely have a printer connected, it is often convenient to store the output to a PDF to be sent to a printer later. On Linux, you might want to install cups-pdf
to print to PDF while practicing instead of wasting the precious printer papers.
pr
Prepares text files for printing.
ls -1 | pr -4 -t
The first part of this pipeline lists the files in one columns. The pr
command then rearranges them to 4 columns. With the -t
option, the headers and footers are not displayed.
lpr
ls -1 | pr -4 -t -o 1 | lpr
The output is under ~/PDF/
.
lp
With characters per inch (CPI) and lines per inch (LPI), this command is provides more functionality
ls -1 | pr -4 -t -o 1 | lp -o page-left=34 -o cpi=20
gs
For graphical printers (like those using PostScript), you can use a2ps
(anything to PostScript)
ls /usr/bin | pr -3 -t | a2ps -o ~/Desktop/ls.ps -L 66