69

How do I read a .man file that's not on my manpath? I know I had a command for this, but now I don't remember, and I can't find the right switch in the man pages for man.

Nagel
  • 2,576
  • 3
  • 22
  • 20

3 Answers3

75

You can try to read your file by doing

man path_to_file

as man will treat the given argument as a file if it finds a slash / in it. For instance

man ./my_test

will open the my_test file, while

man my_test

will look in the standard manual for the given command.

Zombo
  • 1
  • 62
  • 391
  • 407
moongoal
  • 2,847
  • 22
  • 23
  • 3
    After an update (man is now v 1.6f), this doesn't work anymore. I guess it's back to nroff. Annoying, I liked this solution so much better :( – Nagel Apr 27 '12 at 22:41
  • 15
    You can try to read your file by doing `man path_to_file`, as `man` will treat the given argument as a file if it finds a slash `/` in it. For instance `man ./my_test` will open the *my_test* file, while `man my_test` will look in the standard manual for the given command. – moongoal Apr 29 '12 at 13:55
  • @Nagel I forgot to tag you in the last comment, hope it helps – moongoal May 01 '12 at 07:36
  • Awesome, @IceCoder! I can't believe I didn't try that before :P Thank you so much :D – Nagel May 01 '12 at 14:30
18

If your man page is in a non-standard directory location, you can use:

man -M <path to man directory> mymanpage

You can also use the MANPATH environment variable:

MANPATH=<path to man directory> man mymanpage

If you are looking to format a standalone man page, use nroff:

nroff -man mymanpage.1 | less # or your favorite pager
David K. Hess
  • 16,632
  • 2
  • 49
  • 73
  • 1
    Can't get man -M to work. `man -M qnstrn.man` gives me `What manual page do you want?`. `man -M qnstrn.man qnstrn` gives me `No manual entry for qnstrn`. `nroff` works, though. – Nagel Dec 01 '11 at 03:03
  • Ok, I edited the answer to distinguish between a non-standard directory and the case of a standalone page. – David K. Hess Dec 01 '11 at 03:08
  • 2
    To complete the last: `nroff -man mymanpage.1 | pager` (on Debian) or `nroff -man mymanpage.1 | less` (on all Unicies). – Hibou57 Jul 13 '14 at 19:45
  • I managed to view a roff man page I had in my clipboard in this way: `xclip -selection clipboard -o | nroff -man | bat -l man` – Victor Zamanian Feb 02 '23 at 09:26
3

The option -l, --local-file, as documented in man man

man -l ./doc/mypage.1
teknopaul
  • 6,505
  • 2
  • 30
  • 24