[comp.unix.questions] printing out manual pages

raymond@ursa.berkeley.edu (Raymond Yee) (04/29/91)

How do I print out output from the 'man' program or store 'man' output
in a file without having all the extraneous control characters?

Thanks in advance,

Raymond Yee
(raymond@cavebear.berkeley.edu)

c60b-1eq@e260-1g.berkeley.edu (Noam Mendelson) (04/29/91)

In article <1991Apr28.222052.19789@agate.berkeley.edu> raymond@ursa.berkeley.edu (Raymond Yee) writes:
>How do I print out output from the 'man' program or store 'man' output
>in a file without having all the extraneous control characters?

	nroff -man foo.man

-- 
+==========================================================================+
| Noam Mendelson   ..!ucbvax!web!c60b-1eq       | "I haven't lost my mind, |
| c60b-1eq@web.Berkeley.EDU                     |  it's backed up on tape  |
| University of California at Berkeley          |  somewhere."             |

pfalstad@phoenix.princeton.edu (Paul Falstad) (04/29/91)

c60b-1eq@e260-1g.berkeley.edu (Noam Mendelson) wrote:
>In article <1991Apr28.222052.19789@agate.berkeley.edu> raymond@ursa.berkeley.edu (Raymond Yee) writes:
>>How do I print out output from the 'man' program or store 'man' output
>>in a file without having all the extraneous control characters?
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  nroff -man foo.man

Doesn't work for me.  I still get _^H's.

   nroff -man -Tman foo.man | sed 's/_^H//g'

will get most of them...

   nroff -man -Tman foo.man | col -b

will get all of them, if you have col.

--
              Paul Falstad  pfalstad@phoenix.princeton.edu
         And on the roads, too, vicious gangs of KEEP LEFT signs!
     If Princeton knew my opinions, they'd have expelled me long ago.

jik@athena.mit.edu (Jonathan I. Kamens) (04/29/91)

In article <1991Apr28.222052.19789@agate.berkeley.edu>, raymond@ursa.berkeley.edu (Raymond Yee) writes:
|> How do I print out output from the 'man' program

  If your system's man supports the "-t" option, and is correctly configured
to use a typesetter that will work on the printers at your site, then "man -t
program" should send the man page to the printer.

  If your system's man does not support the "-t" option, then get a version of
man that does :-).

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710

jeenglis@alcor.usc.edu (Joe English) (04/29/91)

c60b-1eq@e260-1g.berkeley.edu (Noam Mendelson) writes:
>In article <1991Apr28.222052.19789@agate.berkeley.edu> raymond@ursa.berkeley.edu (Raymond Yee) writes:
>>How do I print out output from the 'man' program or store 'man' output
>>in a file without having all the extraneous control characters?
>
>	nroff -man foo.man
>

That gives you the same output as "the 'man' program" would.
I think what the original poster wanted was a way to get
rid of the junk that nroff inserts to do underlining and 
half-line spacing.

You can do that with a simple sed script:

man foo | sed -e 's/_^H//g' -e 's/^[.//g'

where ^H is the backspace character and ^[ is the
ESCape character; you can type these to the shell by
typing "control-V control-H" and "control-V ESC",
respectively (modulo "stty lnext ..."; control-V is
the default.) If you want to put this command in a 
shell script, control-V also works in 'vi'; in emacs,
I think it's control-Q but don't quote me on that.

That should do the trick.


--jeenglis@alcor.usc.edu

  itp

rac@sherpa.UUCP (Roger Cornelius) (04/29/91)

From article <69425@asparagus.Princeton.EDU>, by pfalstad@phoenix.princeton.edu (Paul Falstad):
>In article <1991Apr28.222052.19789@agate.berkeley.edu> raymond@ursa.berkeley.edu (Raymond Yee) writes:
>>How do I print out output from the 'man' program or store 'man' output
>>in a file without having all the extraneous control characters?
>             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
>    nroff -man -Tman foo.man | col -b
> 
> will get all of them, if you have col.

And if you don't, you can get it from the freely distributable BSD
stuff.  On uunet the files are in ~/bsd-sources/usr.bin/col.

-- 
Roger A. Cornelius          rac@sherpa.UUCP         uunet!sherpa!rac

rickert@mp.cs.niu.edu (Neil Rickert) (04/29/91)

In article <16958@chaph.usc.edu> jeenglis@alcor.usc.edu (Joe English) writes:
>c60b-1eq@e260-1g.berkeley.edu (Noam Mendelson) writes:
>>In article <1991Apr28.222052.19789@agate.berkeley.edu> raymond@ursa.berkeley.edu (Raymond Yee) writes:
>>>How do I print out output from the 'man' program or store 'man' output
>>>in a file without having all the extraneous control characters?
>
>man foo | sed -e 's/_^H//g' -e 's/^[.//g'

 I usually just use:
   man foo | ul -tdumb > file

 If you have 'ul', and if the 'dumb' terminal type is defined in your
termcap or equivalent database as a totally dumb terminal, that should
format it without fancy control characters.

-- 
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Science               <rickert@cs.niu.edu>
  Northern Illinois Univ.
  DeKalb, IL 60115                                   +1-815-753-6940

Tom Christiansen <tchrist@convex.COM> (04/29/91)

From the keyboard of raymond@ursa.berkeley.edu (Raymond Yee):
:How do I print out output from the 'man' program or store 'man' output
:in a file without having all the extraneous control characters?

Well, if you are using my man program (grap w/ anon ftp off convex.com in
/pub/man.shar.Z) then 'man -t topic' will invoke troff for you
appropriately, and 'man -D topic > outfile' will give you an output file
with neither escapes nor other control characters.

--tom

don@muff.webo.dg.com (Don Perkins) (04/30/91)

Try:
%man -Tlp commandname > commandname.ls

ronald@robobar.co.uk (Ronald S H Khoo) (04/30/91)

rickert@mp.cs.niu.edu (Neil Rickert) writes:

> >man foo | sed -e 's/_^H//g' -e 's/^[.//g'
> 
>  I usually just use:
>    man foo | ul -tdumb > file
> 
>  If you have 'ul', and if the 'dumb' terminal type is defined in your
> termcap or equivalent database as a totally dumb terminal, that should
> format it without fancy control characters.

How peculiar.  I just tried that, and the ul that I have (the same as
the one under bsd-sources on uunet, I think) converts the .^H into
carriage return followed by the line to overstrike it with to get the
same effect.  Probably not what the original poster wanted, but useful
nonetheless :-)
-- 
Ronald Khoo <ronald@robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)

woody@udcf.glasgow.ac.uk (Ian Woodrow) (04/30/91)

>|> How do I print out output from the 'man' program


What about      man <subject> | tee <filename>


or to print it direct:

                man <subject> | tee | lpr


--
W@@DY_______________________________________________________________________
 /Ian Woodrow, Computing Service, Uni of Glasgow, GLASGOW G12 8QQ, Scotland \
*  <Dog 'n' Bone:  041-330-4800         | e-mail: woody@udcf.gla.ac.uk>      *
 \__________________________________________________________________________/
-- 
W@@DY_______________________________________________________________________
 /Ian Woodrow, Computing Service, Uni of Glasgow, GLASGOW G12 8QQ, Scotland \
*  <Dog 'n' Bone:  041-330-4800         | e-mail: woody@udcf.gla.ac.uk>      *
 \__________________________________________________________________________/