Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I clean up the output of 'man'?

Little tricks

How do I clean up the output of 'man'?

by  MikeLacey  Posted    (Edited  )
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.
[color blue][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
[/color][/tt]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top