I would like to explore man pages in bash using something similar to the python help('topics') function. Does this exist in bash?
I know the bash equivalent of python's help('modules') would look something like:
dpkg –get-selection
I would like to explore man pages in bash using something similar to the python help('topics') function. Does this exist in bash?
I know the bash equivalent of python's help('modules') would look something like:
dpkg –get-selection
Bash has a help function, but it can only tell you about the Bash built-in functions. Otherwise, you're really stuck with the man command itself, which does have some useful options.
Try the following
man -a intro
man -k *keyword*
man -K *keyword*
M-x woman
which allows you to browse manpages via hyperlinks.
– jordanm
Oct 09 '12 at 01:28
help('topics')
shows the table of contents of a shorter version of Python's reference manual. The closest thing would be a table of contents of the bash manual. This would not include external commands such as dpkg
(which, from bash's point of view, is comparable to a third-party library for Python).
The help
command shows a list of bash builtins and keywords. If you add the name of that builtin (e.g. help alias
), you get the help for that builtin. That's pretty close to what Python offers.
For more complete documentation, like in Python, read the manual. You can read it in a web browser or with the info
program (info bash
). Info is an old hypertext browser, with a markup language that's a lot simpler than HTML. It is mostly used by GNU. If there is no Info manual for a command, the info
program will show the man page instead. Emacs offers a nicer browser for Info documentation.
If you want external commands as well, you will need to reach for the manual of these commands. You can see the list of man pages for commands (a sort of equivalent of help('topics')
for the command line over the whole operating system) with apropos -s 1 ''
(1 is the section for user commands; ''
means to search for the empty string, i.e. return everything). Note that on a typical system, this will return thousands, perhaps even tens of thousands of hits, so it isn't a practical way of exploring the commands. There's just too much stuff.
If you know roughly what you're about, use the apropos
command with a keyword, e.g. apropos -s 1 module
to see a list of commands whose short description includes “module” — it's quite a motley bunch. You can then call man
to browse a specific man page.
Since you mention dpkg
, you're probably using debian (or ubuntu or some other debian derivative).
If so, you could explore man pages for particular packages using dlocate -lsman <pkgname>
(or even dpkg -L <pkgname> | grep '/usr/share/man/.*gz'
if you don't have dlocate
installed) - this will list all man pages belonging to a package.
Mostly useful for targeted RTFM-ing on particular package(s), but not so much for serendipitous discovery.
(full disclosure: i'm the author of dlocate and maintainer of the package in debian, so i'm kind of biased towards using it).
bash
is only one man page – Gilles Quénot Oct 09 '12 at 00:37