Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remove footers from 'man' pages UNIX
If you view 'man' pages in the Terminal (or using something like ManOpen in the GUI), then you may be familiar with the footers that are inserted every so often, as shown in this snippet from "man tcsh":
       ......
......
Sets the environment variable name to value.
(Domain/OS only) (+)

Astron 6.10.00 19 November 2000 1

TCSH(1) TCSH(1)

-e The shell exits if any invoked command terminates
......
......
These footers are somewhat annoying in the terminal, and very annoying if you're trying to print the manual in ManOpen, as they do not align with 'real' page breaks.

Carl Lindberg, the author of ManOpen, went looking for a solution to this problem after I (annoyingly?) asked him why they appeared regardless of what kind of tweaking I did in the Terminal. It turns out that the version of 'groff' (a document formatting utility) installed with OS X is a bit out of date. Installing the new version (1.17.2) removes the page footers, making the man pages print quite nicely in ManOpen.

If you'd like to install the newest 'groff', read the rest of the article for the instructions.

You'll need the Developer Tools installed for this project, as it requires compiling from source.

The first step is to download 'groff' from one of the GNU software mirrors (listed here. Navigate into the 'groff' directory and download groff-1.17.2.tar.gz. Expand this archive, open a Terminal and 'cd' into the newly created folder.

groff compiles quite easily, with no special tweaks required. Simply type:
% ./configure
% sudo make
% sudo make install
This should compile and install the application for you. When it's done, type 'rehash' and you should be good to go! 'man' should no longer insert annoying footers at random spots in your output. If you're still seeing them, make sure that 'usr/local/bin' is in your path, ahead of '/usr/bin'. If that still fails, edit /etc/man.conf and change the references for 'nroff' to the /usr/local/bin directory.

Thanks to Carl for tracking this one down! I've been wanting to print the 100+ page tcsh manual, but the footers in the middle of the pages made it too annoying to read.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,720 views]  

Remove footers from 'man' pages | 8 comments | Create New Account
Click here to return to the 'Remove footers from 'man' pages' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
success!
Authored by: cae on Dec 01, '01 11:50:04AM

I installed the new groff and everything seems to be working as described. Thanks for the tip.



[ Reply to This | # ]
success!
Authored by: ngb on Dec 02, '01 07:44:50PM

I encountered a compile failure until I changed the following steps:

1) unpacked the groff archive with 'sudo gnutar' instead of allowing Stuffit Expander to unpack it
2) used 'sudo ./configure' rather than simply './configure'

As I implemented both changes at once, I'm not sure which was the critical one. I've had problems in the past when I've let Stuffit uncompress what are essentially UNIX archives.

Nate



[ Reply to This | # ]
success!
Authored by: pmccann on Dec 03, '01 09:16:32AM

The change for the better was the switch to the command line version of tar over stuffit expander. All the sudo's could be put back to bed! The general routine is something like:

download package.tar.gz to some directory you're allowed to write to. (You might want to make a special "source" directory to hold your downloaded software; I use ~/src, but you could just as easily make a directory anywhere relatively sane! My old habit has the downside of bloating my user directory, adding a slight complication to my backups. I don't want to back up all the software I've downloaded every time I make a CD out of my home directory.).

gnutar zxf package-blah.tar.gz # the built-in tar also works fine in virtually all cases
cd package-blah
./configure
make
sudo make install # if all was well with the previous command

In this whole procedure the final command is the only thing that (might) require the sudo preface. That's because it'll normally be dumping things into locations such as /usr/bin, /usr/lib, /usr/local/include, and these tend to be writeable only by root. All the preliminary steps involve writing files strictly within the directory in which you unpacked the tarred/gzipped source files, and so can be done as a plain old user. "make install" essentially means "take the compiled versions that we made in the "make" step and cast them into their final resting spots."

Cheers,
Paul




[ Reply to This | # ]
Just for the sake of it...
Authored by: pmccann on Dec 01, '01 01:23:58PM

ManOpen is fun, but if you were really only after an ascii version of a man page without those headers and footers we should be able to hit it with a pretty simply shell script. Here's a two-liner proof of concept that pretty much does that job.

#!/bin/sh
man $1 | col -b | egrep -i -v "^${1}|^[a-z0-9].*[0-9]+$" | uniq >${1}.ascii

"col -b" kills the formatting (underlines and bold text), the egrep call weeds out lines that either begin with the name of the command or fit the bill as a "footer"; strolling through a few different man pages made it clear that there's no real standard format for this, but I think this part of the regular expression catches most. I think that kills the headers and footers pretty efficiently. Piping to unique just kills repeated lines, which in this situation will be multiple blank lines. Finally the output is thrown into "commandname.ascii" in the working directory. Obviously myriad aspects could be cut and polished (eg, you still get the output file if there's no such man page, but the file is of course empty), but the script below gives the guts of what's needed. To use it you can simply save it as, say, "asciiman" in ~/bin, change its permissions to 755 (or 700, or 500, or....), and enter "rehash". Thereafter simply use

asciiman tcsh

for example, to get a minimal ascii version of the tcsh man page in the file tcsh.ascii

Cheers,
Paul



[ Reply to This | # ]
versions that work
Authored by: hagbard on Dec 02, '02 08:45:01AM

For anyone's info, I tried groff-1.18.2, 1.18.1, 1.18 and 1.17.2 and only 1.17.2 compiled and worked fine. The others gave me "warning []: can't break line" during compile, and weird output when run...

so do get version 1.17.2 until someone gives an easy fix.



[ Reply to This | # ]
versions that work
Authored by: mgmorrell on Feb 02, '03 10:14:57AM

Have you had any more progress with groff on osx. I am having a great deal of trouble with some documents. Especially, when eqn is run in groff, if there is an equation that needs a divisor line in it, the divisor line goes all the way past the right of the right margin, and things above the divisor are WAY over, as if the default line length becomes twice as wide as the paper or something. I have tried your suggestion of using groff-1.17.2, but it still has the same problem.



[ Reply to This | # ]
Remove footers from 'man' pages
Authored by: boredzo on Aug 12, '05 02:15:18AM

regarding robg's addition: as of Panther (and possibly earlier versions), you can use man -t tcsh > tcsh.1.ps to get the output in PostScript format. you can then use Preview to convert it to PDF and print it, or use lpr on it directly (lpr tcsh.1.ps).

[ Reply to This | # ]

Remove footers from 'man' pages
Authored by: kd4ttc on Oct 02, '06 10:09:54AM

pstopdf is esier to use to convert from postscript to pdf. Example:

man -t bash | pstopdf -i -o bash.pdf

will create file bash.pdf

---
Steve Holland



[ Reply to This | # ]