Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Little tricks

How do I clean up the output of 'man'? by MikeLacey
Posted: 2 May 01 (Edited 5 Oct 04)

Please browse through FAQ219-2884 and FAQ219-2889 first. Comments on this FAQ and the General FAQ's are very welcome.

This isn't really a question that's very frquently asked - but it's such a neat trick that I thought someone else might like it as well.

I found it on google.com, the code was unattributed.

require 'getopts.pl';
&Getopts ( 'h' ) || ( &usage, exit ) ;

&usage, exit if $opt_h;

$line = 0;

while ( <> ) {
   $rel = $line % 66;
   if ( $rel > 5 && $rel < 59 ) {
      s/. //g;  #this should read s / controlh / / g ;
      $isblank = /^\s*$/;

      print unless $isblank && $wasblank;

      $wasblank = $isblank;

sub usage {
   print <DATA>;



   Convert man output to a printable form

   man -h
   man command | manpr > outfile

   command -- any unix command for which man output is available
   outfile -- destination file for output coming from manpr

   -h -- shows this help info (does not execute)

   Manpr is a filter that converts man output to a format that can be
   sent to any printer capable of printing regular ascii files.
   man ls  | manpr > a.ls    ; xlpr -Fdtype -Pq157
   man rm  | manpr           | xlpr -Fsport -Plw5
   man f77 | manpr | pr -l65 | xlpr -Fsport -Plw5
   man f77 | manpr | pr -l80 | xlpr -Fdtype -Pq157

Back to Perl FAQ Index
Back to Perl Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close