Bash shell output to printer or PDF

Very often I need to print output of man page or save it to PDF, and I need results fast so I can continue debugging my application or whatever I am doing that needed me to browse man pages. If you want to print shell command output you obviously need working printer or if you want to create PDFs you need cups-pdf package(on Debian based distros use apt-get install cups-pdf as root or with prefix "sudo" if you are Ubuntu derivative user). As an example I will print to PDF ls shell command output:

man -t 1 ls | lpr -P PDF

If you are printing to real printer you would use its name instead of "PDF". Lets do the same thing with my printer named "ML-1620":

man -t 1 ls | lpr -P ML-1610

To print to default printer you just omit -P switch altogether like this.

man -t 1 ls | lpr

Cheers!

DevGenii

A quality focused Magento specialized web development agency. Get in touch!

One thought on “Bash shell output to printer or PDF

  1. Anonymous

    Awesome. Thanks for the help. I’ve been wanting to figure out the lpr function for a while, just never got around to it.

    Reply

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *