Dump Man pages to Word
Dump text formatted man pages for all commands in /usr/sbin starting with mk* to testmans:
ls -1 /usr/sbin/mk* | cut -d’/’ -f 4 | xargs -l man | col -b >> testmans
There are lines that appear at the top/bottom of every man page. You may want to use grep to eliminate these.
use grep SOMETEXTINLINE file to see if it gets the right thing, then “grep -v SOMETEXTINFILE file > newfile” will output all lines WITHOUT that text to the new file.
Items to consider using to grep out extra lines:
“Hewlett-Packard Company” - Gets rid of page break fillers between pages on HPUX
‘(1M).*(1M)$’ - only want the ones with two occurences, one at the end of the line, b/c those are at every page top also.
Like so:
grep -v “Hewlett-Packard Company” testmans > testmans1
grep -v ‘(1M).*(1M)$’ testmans1 > testmans
Or put them onto one line if you are confident:
grep -v “Hewlett-Packard Company” testmans | grep -v ‘(1M).*(1M)$’ > testmans1;rm testmans
Open the file in winword and accept “Windows (Default)” as the Text encoding
Knock your top & bottom margins down to the minimum
(Adjusting the left/right margins will likely make no difference, so don’t bother)
(For very small jobs, you could leave top and bottom if you like, I’m usually working close to 100 page though)
Replace: ^p^p^p
with: ^p
-Do this repeatedly. The first time the page count may cut in half. After that you’ll get diminishing returns. Keep doing it until you either get 0 replacements, or the same number repeatedly. Sometimes there will be a string at the bottom of the document that can’t be removed this way.
Finally, make sure there are no blank pages at the end.
Scroll through the document and make sure it doesn’t have any huge white space sections.
Print if you like!
