How to determine the location of the main man page directory

I have an install script for a little program (script) that comes with man pages.

How can I find the location (full path) of the main man page directory?

As manpath gives me a list of directories, I would like a command to get a single directory and in best case the main one in order to copy man-files there.


Solution 1:

Filesystem Hierarchy Standard stated that Manual pages are stored in <mandir>/<locale>/man<section>/<arch> With <mandir> usually be /usr/share/man, and the man<section> that fits best with your case is man1: man1: User programs Manual pages that describe publicly accessible commands are contained in this chapter. Most program documentation that a user will need to use is located here. Other attributes in the path can be found in the standard.

So yes, you can save your man files straight in /usr/share/man/man1, but try to save it in a more specific path to comply with the standard and to, quote from above standard link, "support manual pages which are written in different (or multiple) languages. These provisions must take into account the storage and reference of these manual pages. Relevant factors include language (including geographical-based differences), and character code set".