Question

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?

Was it helpful?

Solution

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

help history

or

help fg

OTHER TIPS

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.

On zsh, the answers above aren't very helpful.

You can look at the shell's own manual with man zsh. It will tell you that the manual is too long (hah!) and provide a list of sections with the actual content. From there we learn that man zshbuiltins explains built-in commands. It's a huge listing each one and its explanation, you can search with /.

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.

There are 3 commands to find more information about shell builtins.

type <command> - Tells you what type of a command it is. Fun fact, type is a shell builtin as well. Type type type and hit enter and see more details.

help - Lists some shell builtin commands by default.

help <command> - Gives more information about <command>

info - This is kind of the man page for shell builtins. Its CLI, of course, but it's hyperlinked. However, it's hard to navigate and it usually takes me around 5 minutes to get a hang of it. Type info and read from the first line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top