When I
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 -w
and 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 man -w
.
/usr/local/opt/w3m/share/man/de:/usr/local/opt/w3m/share/man:/usr/local/opt/binutils/share/man:/Users/xx/opt/anaconda3/share/man:/usr/local/share/man/de:/usr/local/share/man:/usr/share/man:/Library/TeX/texbin/man:/opt/X11/share/man:/Library/Apple/usr/share/man:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man
Out of this, below two has some of the manpages replicated. For example printf
can be found in both path.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man/
/usr/share/man/
If you do ls -l
in 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 $MANPATH
environment variable. Set it to the path you want your man command to look.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.