Open any man page in Preview and save as PDF

If you’re tired of looking over a man page within the Terminal, you can launch any man page into Preview with the following command:
man -t ipconfig | open -f -a /Applications/Preview.app
This example uses ipconfig, but just replace ‘ipconfig’ with any other man page you’d like to read within Preview and it’ll work the same.
Save the man page as PDF
Once the man page is opened within Preview, you can then use Preview to “Save As” and then create a PDF file of the man page for later viewing. I find myself using this command frequently and then saving the PDF to view on my iPad.
If you’re not from a unix background, a ‘man page’ is nothing more than a manual, and they’re really helpful when you’re trying to sort out syntax of various command line features and utilities.

Better still to register this as a function that can be called from the command line.
Add this to the bottom of ~/.profile and you can just type a simple command to open the given man page in Preview:
#Open Man page in Preview
pman () {
man -t “${1}” | open -f -a /Applications/Preview.app
}
Note: After editing this file you need to reload it for the new function to work. Either quit/restart terminal, or type source ~/.profile (or . ~/.profile if you want to be geeky) and the command will be registered.
To call the function, just type pman _function_name
so
pman ls
pman fstab
etc.
Enjoy
CraigMC
PS got this from commandlinefu.com after some google searching
Actually you have to remove the quotes “” from “${1}”, so that it reads ${1} otherwise the quotes will be taken as part of the argument and you will get – No manual entry for “ls”
I spend about 50 minutes a day on trains and usually just tinker with my iPad since it’s the WiFi model and can’t access the web. I must say I never thought of this, but what a great way to read manuals on the iPad and put that commute to work since my company pays overtime for work related learning.
Thanks a bunch.
If you really need the things in pdf form, and you have ghostscript (and thus ps2pdf) installed, you can skip the middleman with man -t ipconfig | ps2pdf – ipconfig.pdf
[...] that man pages can also be read on the go by saving them as a PDF and opening them with iBooks app on the iPad or iPhone. stLight.options({ [...]
thanks, good thing!
but it can be a bit short – without full path to Preview.app
like this:
man -t wget | open -f -a Preview