Where to view man pages for builtin commands?

2020-05-26 08:09发布

问题:

For example, when I type man fg, or man history, the same manpage, BUILTIN(1) will be displayed. There is a list of commands, but not the specification of their usage. Where can I find them?

回答1:

BUILTIN commands don't have separate man pages. Those are covered by help pages. You can do:

help history

or

help fg


回答2:

I have the following bash function defined in my ~/.bashrc:

bashman () 
{ 
    man bash | less -p "^       $1 "
}

This allows me to (in most cases) jump directly to the relevant section of the bash man page for the given builtin. E.g.

bashman fg

jumps directly to:

   fg [jobspec]
          Resume  jobspec  in the foreground, and make it the current job.
          If jobspec is not present, the shell's notion of the current job
          ...

Unfortunately it doesn't work quite so well for some builtins - history is one of them. In those cases, you will have to n through the man page several times to get to the required section.



回答3:

Documentation for commands that are shell builtins are with the man pages for the shell.

See for example: man bash for the history or fg command.