How to send man pages to a file or to printer

I have been trying to learn how to print out the man pages. I have found references to print out each individual page, which is cumbersome. I have found code to unzip man pages for printing etc but nothing that will cycle through and print or send to file all the man pages. At the very least I would like to send them to a word or text file for viewing later.

Note: I have supplied a way for you to see all the man pages in one file. The listing for the man pages will be enormous. You will want to edit the list and have only those man pages you are interested in. That is the million dollar question. Newbies will not know what pages are most important and what could be important to them.

The purpose of this is to get the man pages associated with our personal computers operating system. It can get very frustrating reading a man page on the net only to find that the same command on our computer does not have the same features, or worse, we don't have the command on our computer at all. This code at least gives you the flexibility to get to the man pages and have them print to file in a formatted fashion for retrieval of your choosing.

This gives you a base in which to further improve the code to either print out or to send to html where you can design a static site or a searchable site for the man pages you decide to generate.

This is good for mac mountain lion 10.8.2

First get all the man pages into a text file.
This brings the full path and file name into it.

man -aW "*" > yourfilename #I used manfiles

Next create a batch file to run the code below. Loop through the file line by line pulling out only the file name minus the extension and formatting it to print into the file.

while read line
do
# gets the file name [basename $line] and passes it to awk
# to wipe the extension from the filename and save it to fname

fname=`basename $line | awk -F. '{print substr($1,1)}'`

# calls the man page for each file name (minus the extension)
# formats it in a readable context and appends it to the end
# of the file created here [mannewfls]

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.