8

This question already has an answer here:

So, I needed to figure out how "exec" works. However, doing man exec brings me to a 99% useless man page describing what bash builtins are. It of course also does this with many other man pages such as cd, chdir, etc..

How can I look up the manual page for the actual utility I'm interested in, not the builtins man page?

My OS is Mac OSX, but I've had this on other operating systems as well

marked as duplicate by Gilles bash Dec 23 '15 at 1:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    That man page is not about bash. Are you interested in bash's exec specifically? – Michael Homer Dec 22 '15 at 21:56
8

Getting documentation for shell builtins can be done using the command help. For example:

$ help exec
exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
    Replace the shell with the given command.

    Execute COMMAND, replacing this shell with the specified program.
    ARGUMENTS become the arguments to COMMAND.  If COMMAND is not specified,
    any redirections take effect in the current shell.

    Options:
      -a name   pass NAME as the zeroth argument to COMMAND
      -c                execute COMMAND with an empty environment
      -l                place a dash in the zeroth argument to COMMAND

    If the command cannot be executed, a non-interactive shell exits, unless
    the shell option `execfail' is set.

    Exit Status:
    Returns success unless COMMAND is not found or a redirection error occurs.

Otherwise, one could run man bash and then search within this (perhaps by typing /\bexec\b, in this case, assuming a less-like pager).

  • heh, I wish the "help exec" documentation on OSX was that well formatted. For me it's a single command line exec [-a]... and then a wall of text – Earlz Dec 22 '15 at 21:57
  • That's presumably because OS X comes with an older version of bash; you could use Homebrew to install bash 4. – dhag Dec 22 '15 at 22:02
  • @dhag Could be that the terminal is not set up properly. On unix the shell and terminal are separate processes (and executables). – ctrl-alt-delor Dec 22 '15 at 23:33
  • @richard: It could be a terminal issue, but I actually tried on OS X with the built-in bash, and saw the kind of result that Earlz described, while a newer, brew-installed bash shows the output that I quoted. – dhag Dec 23 '15 at 13:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.