IntelliJ Java IDE
The moose likes Linux / UNIX and the fly likes printing man pages Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Reply Bookmark "printing man pages" Watch "printing man pages" New topic
Author

printing man pages

Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
How can one print the man pages? Or at the very least pipe the formatted output of 'man <topic>' to a text file?
Thanks,


Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7231

man sumpn > file.txt
or
man sumpn | lp


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
This is one of those no-so-frequently-asked questions. As I'm sure you you would find, Michael, if you tried this, you either lose the formatting, mess up the output, or get a whole bundle of _^H in an attempt to underline stuff.
Anyway, the classic solution is

see

for more details.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Thanks!
I used a combination of the two replies.

It even kept the formatting.
Thanks a lot.
George Brown
Ranch Hand

Joined: Sep 26, 2000
Posts: 919
Alternatively there are various converters to turn manpages into HTML pages, for example you could use man2html or there are hypertext interfaces to manpages such as this one or that one.
My point being that once you've made them available as HTML pages it makes them very easy to print from any bogstandard windoze PC or macintosh assuming you have one available. A google search should yield more web-based manpages.
HTH.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7231

Originally posted by Frank Carver:
This is one of those no-so-frequently-asked questions. As I'm sure you you would find, Michael, if you tried this, you either lose the formatting, mess up the output, or get a whole bundle of _^H in an attempt to underline stuff.
Anyway, the classic solution is

see

for more details.

Must be a Linux thing; I have no issues actually using this technique all the time on Solaris. I do remember running unix2dos against output to a file, but since I rarely want a file of a man page I don't think too much of the ^M's in the file.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
It's not just the ^M, honest. By default, the output of "man" attempts to do underlining by emitting a character, a backspace and an underbar for each underlined character. The purpose of "col -b" is to process these sequences into acceptable printable output. I'm sure it was the same on Solaris last time I looked ( I haven't got access to a Solaris machine right now, or I would try it ).
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7231

I'll try it today against a 'problematic' man page and post my findings. Now I'm curious.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 12510

Historically man boldfaced critical headings by backspacing and overprinting (something that works a lot easier on a teletype terminal than a laser printer).
Which is why the extra voodoo. Some printers will honor the backspace (though not so frequently will it overprint into boldface), but for the rest, you want that magic or you get ugliness.


One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
 
 
subject: printing man pages
 
Threads others viewed
Mount points
obtain root privileges
Command to count the lines of code
top 20 linux commands
WA #1.....word association
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com