Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2005-03-21
Medium Priority
Last Modified: 2010-03-17
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.


Question by:spyro0
  • 3
  • 2
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13595654
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

Author Comment

ID: 13595985

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...


LVL 15

Accepted Solution

veedar earned 1000 total points
ID: 13597416
You need col -b for example...

man  date | col -b > date.man

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 13604093

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?
LVL 15

Expert Comment

ID: 13607205
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

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

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

Good Luck,

LVL 15

Expert Comment

ID: 13607231
Oh and ask about your question id's
on the community support page

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question