Finding The Right Man (Page)
by Chris Josephes
I work in multiple Unix flavor environments. Sometimes commands on one host aren't where I expect them to be on another. In one or two cases, my PATH variable could have 8 directories for me to search.
A long time ago, I wrote a .bashrc script to build my PATH based on what's actually available on the host system.
# Set the path
for p in $PATHLIST
if [ -d $p ]; then
It goes from specific directories, to root access directories, to common directories, then least used directories. If the directory doesn't exist, it won't be in the PATH variable.
That worked fine for awhile, but I had a problem with manpages. Some manpages on certain commands wouldn't reflect the actual command I'm calling. I made another modification to the script to build a dynamic MANPATH.
# Set the manpath
for m in $PATHLIST
if [ -d $BASE/man ]; then
If there's a manpage directory outside of the scope of PATHLIST, just add it to the end of the variable in the form of "/path/to/bin". If the bin directory doesn't exist, it won't be added to the command search path. But, if the corresponding man path exists, it will be added.