24

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?

tripleee
  • 175,061
  • 34
  • 275
  • 318
franklsf95
  • 1,182
  • 12
  • 23
  • Perhaps see also the [Bash Reference Manual.](https://www.gnu.org/software/bash/manual/html_node/Builtin-Index.html) – tripleee Jan 21 '21 at 11:02

5 Answers5

24

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

help history

or

help fg
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 3
    Works for bash, but it seems zsh does not have a built-in help. – franklsf95 Apr 11 '14 at 00:22
  • 6
    `zsh` has extensive, but unconfigured by default, support for accessing help extracted from the man pages. See "Accessing On-line Help" in `man zshcontrib` for details. – chepner Apr 11 '14 at 00:47
  • Worth noting is that the `help` entries in the forthcoming 4.3 release seem to have been improved, at least in how they are formatted. Also, they've fixed the bug where `help read` gives you the entires for `read` and `readonly`, due to substring matching. – chepner Apr 11 '14 at 00:51
  • 1
    @franklsf95: Since you tagged your question as bash that's my answer was centered on that. – anubhava Apr 11 '14 at 07:27
  • for OS X, partly solved, [What do the numbers in a man page mean? - Unix & Linux Stack Exchange](https://unix.stackexchange.com/questions/3586/what-do-the-numbers-in-a-man-page-mean); if you try `brew install coreutils`, maybe fix this problem, - [Install and Use GNU Command Line Tools on macOS/OS X - Top Bug Net](https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/) – Mark Simon Nov 20 '18 at 07:03
  • 2
    if you online, use [explain shell in command line](https://gist.github.com/markhuyong/877aeb2dcedc58d0a3d107c1109945b4) – Mark Simon Nov 20 '18 at 07:55
10

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.

Digital Trauma
  • 15,475
  • 3
  • 51
  • 83
9

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

Donentolon
  • 1,363
  • 1
  • 10
  • 17
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.

ThatOneDude
  • 1,516
  • 17
  • 20
0

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.

Ativerc
  • 93
  • 1
  • 7