7

I'm looking for a way to query the linux man pages through an API, the closest I've found is http://linux.die.net/man, however there the commands are split into 8 sections, e.g. gcc is in section 1: http://linux.die.net/man/1/gcc, and as it's not actually an API so you get a full html page (sidebar and ads included) in return.

Before I plough on and try to make one, does something like this already exist?

Phil
  • 1,110
  • 1
  • 9
  • 25

2 Answers2

4

Why not just use your local man pages? Man pages are just compressed text files of nroff source code. nroff is confusing and weird, but should be doable. A man page creation guide should make it clear.

For the location of the files, use man -w COMMAND. On my machine man -w man gives me /usr/share/man/man1/man.1.gz. So my man files are stored in the subdirectories of /usr/share/man. Probably would be easy to index from there.

If you look hard enough, someone probably already wrote a man page parser.

ssmy
  • 156
  • 2
  • Yep, this looks like the best route. Annoyingly searching for man page parsers returns man pages about parsers :) Thanks, Phil – Phil Jun 26 '12 at 14:30
  • The creation guide link says, that the info is deprecated. – sja Sep 16 '14 at 10:24
  • 1
    Parser for troff/groff files: https://www.npmjs.org/package/manolo – sja Sep 16 '14 at 10:31
0

Yes this seems to work.

[root@test~]# man -w ls
/var/cache/man/cat1/ls.1.lzma (<-- /usr/share/man/man1/ls.1.gz)
[root@test ~]#

You can also check online man pages at http://www.go2techschool.com/linux-all-commands.php