Where to view man pages for builtin commands?

2020-05-26 07:38发布

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?

3条回答
相关推荐>>
2楼-- · 2020-05-26 08:04

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

help history

or

help fg
查看更多
劳资没心,怎么记你
3楼-- · 2020-05-26 08:14

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 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.

查看更多
虎瘦雄心在
4楼-- · 2020-05-26 08:21

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.

查看更多
登录 后发表回答