"man" command returning duplicated results in mac terminal
man -k "^printf"
in terminal, it returns duplicated results below:
printf(1) - formatted output printf(1) - formatted output printf(3), fprintf(3), sprintf(3), snprintf(3), asprintf(3), dprintf(3), vprintf(3), vfprintf(3), vsprintf(3), vsnprintf(3), vasprintf(3), vdprintf(3) - formatted output conversion
And, When I
man -k 1
It also returns a bunch of duplicated results.
It's a new M1 MAX Mac, I didn't even do any setting changes yet, but the problem above is actually happening. What's wrong with my new Mac?
You could do
man -wand see where the man looks for manpages. This issue (duplication of results while using
man -k printf) arises, if your system has copies of manpages in multiple path.
In my system there are multiple man paths. See below the output of my
Out of this, below two has some of the manpages replicated. For example
printfcan be found in both path.
If you do
ls -lin the
MANPATH, you will see that both has copies of some of the same manpages.
> ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man/ man1 man2 man3 man4 man5 man6 man7 man8 man9 mann > ls /usr/share/man/ man1 man4 man5 man6 man7 man8 man9 mann
In short, when you do
man -k somecommand, it displays results from all the paths contained in
man -w. If you want to avoid that you need to change the
$MANPATHenvironment variable. Set it to the path you want your man command to look.