I've been working on a Routing Protocol and looking at legacy code for different routing protocols. I constantly find different macros where I it is very hard to find it in the header files because they include ~20-50 headers. Besides looking up the macro on the Internet is there any way by finding their definitions in the man pages?

For instance: INADDR_ALLHOSTS_GROUP macro which I eventually found in "netinet/in.h" but the man page never discussed the macro. Is there a way to use the man pages when you are trying to search for such things or would I need to go another way?

  • How people looks for information: info/man page, source. That is. If the man pages doesn't satisfice you, just peek at the source (like you did). – Braiam Feb 11 '15 at 19:10

You can use the -K (--global-apropos) option to search for text in all manual pages. However this is rather slow (as the man(1) man page says, you should also specify a section to reduce the number of pages that need to be searched) and will work only if the macro in question is described in some man page. If the man pages don't describe the macro, then you should obviously find another way.


I posed this question to my mentor and he said to use grep, so I tried it out and I succeeded. Grep is an absolutely amazing tool! The code I used to find the macro was grep -rl "INADDR_ALLHOSTS_GROUP" * and I ran it from the /usr/include directory.

  • But this doesn't answer your own question: you asked how to find documentation in the manpages. The /usr/include directory doesn't contain man pages, just header files. Moreover grep won't work on all man pages because they are typically compressed (and zgrep doesn't support the -r option) and also because they have there own format. – vinc17 Feb 14 '15 at 13:41
  • Grep does answer my question because my main purpose behind my question is to find the MACRO!!! I am able to find the macro in an efficient manner without resorting to use the Internet! I think you focused too much on the first part of my question whereas I am perfectly fine with obtain another means to answer my initial question. – Jacob Bryan Feb 17 '15 at 18:07
  • I do appreciate your answer nonetheless! I did learn something but it didn't exactly answer my question. – Jacob Bryan Feb 17 '15 at 18:08
  • Well, your question explicitly mentioned the term "manpages", while /usr/include does not contain man pages. In general macros are described in the man pages. For instance, to know which man pages deal with the F_GETFL macro, man -wK F_GETFL is the solution. Header files in /usr/include do not always constitute a good documentation because they may not say important things concerning the API. Other documentation can sometimes also be found under /usr/share/doc or in info manuals (searchable with info -k). – vinc17 Feb 17 '15 at 20:53
  • I tried the manpages, macro wasn't there, so I asked if I needed to go another way and I did. If you can understand the second part 'or do I need to go another way?' Then I seriously question your intent behind arguing your point. – Jacob Bryan Feb 17 '15 at 21:43

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.