Printing from commandline

When you have a lot of documents to print, perhaps a bunch of papers you want to read, it can be a bit annoying to print these one by one.
A nice solution can instead by to do this from the commandline. The ‘lp’ tool is quite nice and can be modified to do a bunch of stuff.
This can be done something like this:

This will print document.pdf, pages 1,2,3,4,8 with double sided printing and a staple in the top left corner. The -n flags says that we want two copies.

To make things easier I use an alias constructed like this:

This is the most common way I print documents. Double sided and with a staple.

Now I can print any document by simply typing

Or if I want to print all files pdfs in a folder, it’s just a simple loop

This has been tested on OSX 10.11, but should work on many unix-like systems.
One thing to be vary of is that it might change with your printer and printer-drivers.