×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

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.
[tt]
#!/usr/bin/perl

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;
      
   }
   
   $line++;
}


sub usage {
   print <DATA>;
}

__END__

Name:
   manpr

Purpose:
   Convert man output to a printable form

Usage:
   man -h
   man command | manpr > outfile

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

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

Discussion
   Manpr is a filter that converts man output to a format that can be
   sent to any printer capable of printing regular ascii files.
      
Examples
   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
[/tt]

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