Systems often have multiple versions of binaries and the one selected depends on the priority in $PATH
. For instance, the system I am using has a couple version of sort:
$ which sort
~/coreutils-8.25/bin/sort
$ ~/coreutils-8.25/bin/sort --version | head -n 1
sort (GNU coreutils) 8.25
$ /bin/sort --version | head -n 1
sort (GNU coreutils) 8.4
On the system I am using, the version from GNU coreutils 8.25 is selected by an invocation of sort
because of its precedence in PATH
. However, the MANPATH
environment variable on the system has been established such that the man page for the sort
from GNU coreutils 8.4 is displayed (i.e., for /bin/sort
, which is not the binary having precedence).
A three-part question arises from this scenario.
First, is there a simple way to instruct man
(or the shell) to use or produce a form of MANPATH
that reflects PATH
, or must one do this manually (i.e., by finding the paths to the man pages that are associated with each entry in PATH
and then concatenating these man paths in the same order as PATH
, an exercise that would have to be repeated any time a change is made to PATH
)? Were there a mechanism to establish concordance between PATH
and MANPATH
, then the expected man page would be displayed automatically, avoiding the problem of inadvertently reading a man page for a version other than the one used by default.
Second, is there a command that allows one to quickly determine the path of the default man page (e.g., something akin to which "man sort"
, which would report the path of the man page that is displayed when executing man sort
). For instance, when I type man sort
, I have no indication of the specific file on the system that is being delivered to the pager.
Third, is there a way to obtain the man page for an explicit version of a command (something like man ~/coreutils-8.25/bin/sort
in my case for the GNU coreutils 8.25 version of sort, rather than having to track down the associated file, which in my case can be found to be ~/coreutils-8.25/share/man/man1/sort.1 or ~/coreutils-8.25/man/sort.1).
coreutils
. Why? It's generally a bad idea to have local installs unless really necessary, and in this case, I don't see the necessity. – Faheem Mitha May 06 '16 at 23:35--parallel
option forsort
– user001 May 07 '16 at 02:14