1

Entering the following command prints duplicates as shown below. Not all lines print twice but some do. What gives?

XXXX:~ XXXX$ man -k pid
pid(ntcl)                - Retrieve process identifiers
pidpersec.d(1m)          - print new PIDs per sec. Uses DTrace
rwbypid.d(1m)            - read/write calls by PID. Uses DTrace
syscallbypid.d(1m)       - syscalls by process ID. Uses DTrace
git(1)                   - the stupid content tracker
Sub::Exporter::Cookbook(3pm) - useful, demonstrative, or stupid Sub::Exporter tricks
Tcl_DetachPids(3tcl), Tcl_ReapDetachedProcs(3tcl), Tcl_WaitPid(3tcl) - manage child processes in background
getpid(2), getppid(2)    - get parent or calling process identification
pid(ntcl)                - Retrieve process identifiers
pidpersec.d(1m)          - print new PIDs per sec. Uses DTrace
pthread_setugid_np(2)    - Set the per-thread userid and single groupid
rwbypid.d(1m)            - read/write calls by PID. Uses DTrace
syscallbypid.d(1m)       - syscalls by process ID. Uses DTrace
wait(2), wait3(2), wait4(2), waitpid(2) - wait for process termination
git(1)                   - the stupid content tracker
XXXX:~ XXXX$ 
  • I can't replicate. Can you please provide more information about your environment? – jasonwryan Feb 7 '14 at 21:39
  • @jasonwryan TERM_PROGRAM=Apple_Terminal SHELL=/bin/bash – les Feb 7 '14 at 21:47
  • 1
    Do you perhaps have the same directory included more than once in your $MANPATH variable? – Mark Plotnick Feb 7 '14 at 21:47
  • Please post your MANPATH if you can – slm Feb 7 '14 at 22:23
  • 1
    No dups in there. I would check if any of those paths are links, also check with man and the -d switch to see what directories it's looking in too might shed additional light. – slm Feb 7 '14 at 23:10
3

I would assume since it's doing a regex search through the descriptions and the man page names that it's finding multiple hits and showing those pages multiple times.

   man -k printf
       Search the short descriptions and manual page names for the  keyword  
       printf  as  regular  expression. Print out any matches.  Equivalent to 
       apropos -r printf.

If it's that annoying you can filter the output using sort -u.

$ man -k pid|sort -u
getpid (2)           - get process identification
getpid (3p)          - get the process ID
getpidcon (3)        - get SELinux security context of a process
getpidcon_raw (3)    - get SELinux security context of a process
getppid (2)          - get process identification
getppid (3p)         - get the parent process ID
git (1)              - the stupid content tracker
mysql_waitpid (1)    - kill process and wait for its termination
pidgin (1)           - Instant Messaging client
pid (n)              - Retrieve process identifiers
pidof (8)            - find the process ID of a running program.
pidstat (1)          - Report statistics for Linux tasks.
Proc::Killfam (3pm)  - kill a list of pids, and all their sub-children
Sub::Exporter::Cookbook (3pm) - useful, demonstrative, or stupid Sub::Exporter tricks
Tcl_DetachPids (3)   - manage child processes in background
Tcl_WaitPid (3)      - manage child processes in background
waitpid (2)          - wait for process to change state
waitpid (3p)         - wait for a child process to stop or terminate

If you need to debug your man environment you can always use the -d switch. This will report back the various paths and configurations of your man setup too.

$ man -d
From the config file /etc/man_db.conf:

Mandatory mandir `/usr/man'.
Mandatory mandir `/usr/share/man'.
Mandatory mandir `/usr/local/share/man'.
Path `/bin' mapped to mandir `/usr/share/man'.
Path `/usr/bin' mapped to mandir `/usr/share/man'.
Path `/sbin' mapped to mandir `/usr/share/man'.
Path `/usr/sbin' mapped to mandir `/usr/share/man'.
Path `/usr/local/bin' mapped to mandir `/usr/local/man'.
Path `/usr/local/bin' mapped to mandir `/usr/local/share/man'.
Path `/usr/local/sbin' mapped to mandir `/usr/local/man'.
Path `/usr/local/sbin' mapped to mandir `/usr/local/share/man'.
Path `/usr/X11R6/bin' mapped to mandir `/usr/X11R6/man'.
Path `/usr/bin/X11' mapped to mandir `/usr/X11R6/man'.
Path `/usr/games' mapped to mandir `/usr/share/man'.
Path `/opt/bin' mapped to mandir `/opt/man'.
Path `/opt/sbin' mapped to mandir `/opt/man'.
....
2

man -k searches the directories listed in the MANPATH environment variable.  If you have some directory listed more than once, or if you have “man page” files duplicated in more than one of the directories (including links), files will be reported more than once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.