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

Reading man pages in the current directory UNIX
Sometimes you want to take a look at a 'man' page that is not in the MANPATH or in a directory where man searches for it ... as a possible example, when looking at a package you're about to install. Newer GNU-versions of 'man' have a switch for this, but the Jaguar-version doesn't have it ... so here's a little shell script that does the job :

#!/bin/sh
#
# format and display a file like man
#
[ -z $1 ] && echo "Usage : $(basename $0) file" && exit 1
groff -mman -TASCII $1 | less
Just put it in a folder in your search path to use it. Oh and don't forget to make it executable with chmod +x script_name.

Hope this can help someone someday...
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[7,143 views]  

Reading man pages in the current directory | 10 comments | Create New Account
Click here to return to the 'Reading man pages in the current directory' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Reading man pages in the current directory
Authored by: bluehz on Apr 03, '03 10:53:35AM
Not sure if the Fink version of man is GNU (I suspect it is) but if you have the Fink version of man installed you can simply:

man /path/to/manfile

to display any manfile that is not installed.

While we are on the subject of manpages...

I personally prefer reading man pages through either openman or Safari (or other browser). There is a very nice cgi interface called "man-cgi" located here http://www.softlab.ntua.gr/~christia/man-cgi.html

Man-cgi
browse UNIX man pages through WWW
version 1.15
Man-cgi is shell-sed-awk script which converts on the fly the output of the "man" command to HTML.

This allows you to quickly search and read local man pages on your machine using a url like:

http://localhost/cgi-bin/man-cgi?ls

or better yet create a Bookmarks Bar bookmark with this URL in it (broken into two lines for display below):

javascript:void(q%3Dprompt('What%20Man%20pages%20would%20you%20like%20to%20view?',''));
if(q)void(location.href='http:%2F%2Flocalhost%2Fcgi-bin%2Fman-cgi%3F'+escape(q))

or drag this to bookmarks bar to add the above bookmarklet and it will pop up a simple dialog that allows you to enter your search term.

I just prefer the wide open spaces of a browser for reading long and complex man pages.



[ Reply to This | # ]

Reading man pages in the current directory
Authored by: Jay Sachs on Apr 03, '03 11:50:48AM
You can also do
  man -M . topic
with all the 'man' programs I've used.

[ Reply to This | # ]
Reading man pages in the current directory
Authored by: Anonymous on Apr 03, '03 11:58:26AM
Newer GNU-versions of 'man' have a switch for this, but the Jaguar-version doesn't have it

Actually, the switch is -M, which in all standard versions of man (not just GNU man).

If the man page is properly sorted (in a man/man? subdirectory), you can simply do "man -M man PAGE".

Example:
$ ls man
man1 man2 man3 ...
$ ls man/man1
blah.1
$ man -M man blah

If you have installed a standard UNIX software package in a particular root directory (ex: /usr/local/apache), there is probably a local man directory containing all of the correct man pages (/usr/local/apache/man). If the manpages are just left hanging around in the installation root directory, the installer needs to be bonked on the head. Properly using the man command, one could either type "man -M /usr/local/apache/man httpd", or add /usr/local/apache/man to their MANPATH:

Bourne shell and similar others (made permanent by adding to .profile):
$ MANPATH=/usr/local/apache:$MANPATH
$ export MANPATH

C shell and similar others (made permanent by adding to .cshrc):
% setenv MANPATH /usr/local/apache:$MANPATH

Then all you have to do is "man httpd".

If someone is instructed to write a script to perform a task they have to (a) create the script every time they want to perform the task, (b) make a copy of the script in every directory that contains a stray man page, (c) make one copy of the script and call it with its full path every time they want to use it, (d) put the script in a standard UNIX binary location such as /usr/local/bin (which isn't always a good idea), or (e) edit their .cshrc or .profile to include the script's directory in their search path - all of which are silly hacks that make things more difficult than they have to be. For instructions on using the man command the correct way, read its manpage the usual way (below). If you do have a bunch of man pages hanging around in misc areas, you could always sort them into a new man directory (maybe /usr/local/miscman) and add that to your MANPATH.

$ man man

---
--
Gypsy

[ Reply to This | # ]

Reading man pages in the current directory
Authored by: rkt on Apr 04, '03 09:58:22AM

actually, it's recommended that you no longer hand configure your MANPATH, as its now handled automatically by /usr/bin/manpath...

see: man manpath



[ Reply to This | # ]
Reading man pages in the current directory
Authored by: WillyT on Apr 04, '03 11:11:43PM

Sorry but this won't find most of my man pages. If I "unsetenv MANPATH" then run manpath I lose most of finks manpages and all of X11's manpages. I'll continue to keep MANPATH set.

I remember a while back that an OSX update unset my MANPATH and I'm wondering where the heck did all my manpages go.



[ Reply to This | # ]
Reading man pages in the current directory
Authored by: Anonymous on Apr 05, '03 05:31:07PM
The problem with relying on site-wide manpath's is that it is tailored to the system, not the user. A real everyday example would be software I write. I install the software in my home directory ($HOME/bin, $HOME/man, $HOME/etc, ...). I don't want everyone else on the system reading my manpages. In fact, I keep my home directory permissions set at 700. Does my software belong in /usr/local? Not if it's a utility that only I would use (software only a mother could love, trust me!). Not if it's still buggy. Not if I don't want others using it. Solution? A custom MANPATH (the standard UNIX way).

Really, I'm not trying to say the original suggestion of writing a script is wrong. In fact, it's a nice script - short and simple. The point I'm trying to make is that provisions were put in place to deal with non-sitewide man pages 20 years ago in UNIX. The script re-invents the wheel - and the old wheel is still better.

---
--
Gypsy

[ Reply to This | # ]

Reading man pages in the current directory
Authored by: mosch on Apr 03, '03 06:22:40PM

groff -mman -Tlatin1 $1 | less gives nicer output for viewing in terminal.

The -M tip is only valid if you have a properly configured set of man directories, if you just have a random manfile, the poster's method of reading the man file is more likely to be generally useful (though I recommend using my minor modification)



[ Reply to This | # ]
Reading man pages in the current directory
Authored by: midan23 on Apr 04, '03 03:02:27AM

Thats exactly the reason for my little shell script ...
(I had more than one source package with only a simple man directory containing all it's man pages ...)

I'll try your little modification, it's nice ... thank you for this.

I made another one :
I entered this
[ ! -f $1 ] && echo "File not found in current directory !" && exit 1
just before the groff line ...


---
Linux is for networking
Mac is for working
Windows is for Solitaire



[ Reply to This | # ]
Reading man pages in the current directory
Authored by: kholburn on Apr 03, '03 06:30:08PM

open -a ManOpen <manpage.1>

If you've made man pages openable by ManOpen then just:
open <manpage.1>



[ Reply to This | # ]
Reading man pages in the current directory
Authored by: AndyF on Apr 04, '03 11:36:42PM

As an alternative to executing groff directly, you can instead use "grog", which scans the file and determines the command. So "grog -Tascii /usr/share/man/man1/javadoc.1" will give "groff -Tascii -t -man /usr/share/man/man1/javadoc.1" -- the tbl preprocessor is required.

The shell script becomes `grog -Tascii .... ` | less



[ Reply to This | # ]