help


help (get help for shell built-in commands)

The help command is a shell builtin that provides information specifically about other shell builtin commands like cd, echo, and history. It offers a quick way to understand the syntax and options of commands that are part of the shell itself, rather than separate executable programs.


Example 1: Basic Help Listing

# Display a list of all available shell builtin commands with brief summaries
help

Explanation

When executed without any arguments, the help command provides a list of all builtin commands that the current shell supports, giving you an overview of available internal tools.


Example 2: Getting Help on a Specific Builtin

# Show detailed help information for the 'cd' builtin command
help cd

Explanation

This command displays the full help text for the specified builtin, cd. The output details its purpose, usage syntax, and any available options.


Example 3: Short Description Option

# Display only a short, one-line description of the 'history' command
help -d history

Explanation

The -d option is used to get a concise summary of a builtin command. This is useful when you need a quick reminder of what a command does without all the details about its options.


Example 4: Displaying Usage Synopsis

# Show only the usage syntax for the 'echo' command
help -s echo

Explanation

When you only need to see the syntax of a command (how to structure it with its arguments and options), the -s option provides just that information, omitting the longer descriptive text.


Example 5: Manpage-like Format

# Display help for the 'let' command in a format similar to a man page
help -m let

Explanation

The -m option formats the help output in a structure that resembles a traditional man page, with sections like NAME, SYNOPSIS, and DESCRIPTION. This provides a more formal and detailed layout.


Example 6: Searching for Builtins with a Pattern

# Find and display help for all builtins containing the word 'alias'
help alias

Explanation

You can provide a pattern to the help command. It will then display detailed help for all builtin commands whose names match that pattern, such as alias and unalias in this case.


Example 7: Getting Help for the 'source' command

# Show help information for the 'source' builtin, also known as '.'
help source

Explanation The source command, which can also be invoked with a single dot (.), is a shell builtin used to execute commands from a file in the current shell. This example shows how to get its documentation.


Example 8: Understanding the 'exit' command

# Display help information for the 'exit' builtin command
help -s exit

Explanation This command shows the usage synopsis for the exit builtin. It clarifies how to terminate the shell and optionally provide a specific exit status code.

In other UNIX shells, like the original Bourne shell (sh) found on older systems, a dedicated help command for built-ins may not exist. Users would typically rely on the main man page for the shell itself (e.g., man sh) to find information about its internal commands.