Skip to content

Instantly share code, notes, and snippets.

@enricobacis
Created January 4, 2017 11:00
Show Gist options
  • Save enricobacis/27c494a25dd3f9aecd2737cc322f77d4 to your computer and use it in GitHub Desktop.
Save enricobacis/27c494a25dd3f9aecd2737cc322f77d4 to your computer and use it in GitHub Desktop.
command-line-printing in Unix/OSX

command-line-printing

to print the file filename.pdf using the default printer:

lpr filename.pdf

you can also specify the printer name using -P printername:

lpr -P printername filename.pdf

in order to know the name of all the available printers:

lpstat -p

lpr also has multiple options that can be explored using:

man lpr

Two of the most common options are:

-o sides=two-sided-long-edge
-o sides=two-sided-short-edge

and can be used as follows.

lpr -o sides=two-sided-long-edge filename.pdf

in order to print all the *.pdf file in the current directory, use a bash loop:

for PDF in *.pdf; do echo "printing $PDF"; lpr -o sides=two-sided-long-edge $PDF; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment