Link to home
Start Free TrialLog in
Avatar of spyro0
spyro0Flag for United States of America

asked on

Saving UNIX manual man pages into plain text files with proper formatting

I would like to save the formatted plain text output of UNIX (HP-UX) manual pages into plain text files for later searching.
I have found a partial solution in the  question listed below which is something like:

man cut | nroff -Tlp | sed 's/.^H//g' | tee cut.ascii.man | more
(The more is there for troubleshooting)
=====================================

The problem is that this wraps on column 66!!

=====================================
refferenced question:
=====================================
Solution Title: how to output the man pages to a file?
asked by academic on 08/31/2000 12:29PM PDT
=====================================
(By the way how do I get the actual question id for the above so that I don't have to reffer to it by title and date?)
The original solution called for groff and -Tascii.
However,  problem is that:
a) I am working in a corporate HP-UX 11.11 environment with little control of SA stuff.\
b) I do not have groff (GNU roff -right?) so I used nroff and substituted -Tlp.
c) All is well except that the output is wrapped for me on COLUMN 66 !

It looks like nroff is using /usr/lib/term/termlp.  Perhaps it thinks the output device is only 65 chars?
I don't know its format and can't control it if I did.

My main motivation is to be able ot search frequently used man pages with vi.
I don't have less.  I could probably have it but would still rather have a file with vi.

My main reason for this is that I am using putty to connect to HP-UX as an xterm and have set colors for approximately black on white.
man insists on lighting up inverse video which makes it look unreadable as it happens in so many places.

A workaround would be to ask the xterm, man or putty not to do the inverse video.
However, I fear this also involves termcap, another system resource over which I have no control.

I would like to award 250 points if the moderator  allows the post.  If it is not allowed please answer my questions in some detail.

Thanks.




Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Maybe I'm missing something - it's quite possible as I'm not great in Unix and I've never even touched HP UX.  But why not just redirect output to a file?

man command > command.man
Avatar of spyro0

ASKER


Try it.  You'll see that all of the terminal control chars are embedded in the file.  This is not an HP-UX issue but common to all UNIXs with these commands, i.e. all as they are part of the original distributions from the Bell Labs days.  This embeded chars are the problem in this case..

I have something to add in the way of a workaround.  I just found a link for some wonderful link for nicely formatted HTML UNIX man pages on hp's site.  The following link reffences the HP-UX 11.0 set.  This will do for me for now, but I would still like an answer to the nroff battle...

Thaniks for the comment in any case...

http://www.docs.hp.com/en/B2355-90680/index.html 

ASKER CERTIFIED SOLUTION
Avatar of veedar
veedar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spyro0

ASKER

veedar,

Thanks so much this was the pefect and simplest solution.  It does exaclty want I wanted -plain text properly formatted manual pages which I can then use vi to search in.

Can you tell me how I can change the pagination i.e. the number of lines per page.
I did a man man and did not see an option.
What is the mechanisim which determines the number of lines per page, the number of columns per page etc.
I suspect that it is nroff and /usr/share/lib/term/* issue but would love more details.

I would like to print the manual pages using a smaller font and so need to control pagination.
I can explore alternatives such as converting the pages to postscript first and then sending them to the  printer however, I would like a better understanding of the issue.

On a related issue, the issue which started this question was the liberal use of inverse video in my putty/xterm.
Do you know how I can turn inverse video off on my putty/xterm.  I am using blackish on off white for the display and the inverse video is very difficult to read.  I'll be happy to open another question if you like.

Also my original posting asked how to get the question id of an answered question -any idea?
spyro0,
I haven't worked on HP-UX in a while but I do recall the inverse video
annoyance.  What were they thinking?

Anyway to change the pagination I would change the deafults used by man,
See the $PAGER environment variable as seen from "man man". You can change
to a different pager or change the options to the default pager, check out man
pager.

I  think you are on the right track with postscript I used to use postscript
commands to have 2 or 4 pages shrunk and fitted to print on one page. I do
not recall the details, I think maybe the postprint command was involved.

Sorry I can't think of anything off hand to help with your putty/xterm issue.
Maybe repacing xterm with rxvt or another might do it.

Let me suggest you check out the HP-UX resources listed at http://www.stokely.com
/unix.sysadm.resources/faqs.a-m.htm

stokely.com has been around for years and is a great and trusted resource for UNIX admins.

Good Luck,
V




Oh and ask about your question id's
on the community support page
https://www.experts-exchange.com/allTopics.jsp?t=180