bash help

執行

$ help

顯示

GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

 job_spec [&]                                                 history [-c] [-d offset] [n] or history -anrw [filename] >
 (( expression ))                                             if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMAND>
 . filename [arguments]                                       jobs [-lnprs] [jobspec ...] or jobs -x command [args]
 :                                                            kill [-s sigspec | -n signum | -sigspec] pid | jobspec ..>
 [ arg... ]                                                   let arg [arg ...]
 [[ expression ]]                                             local [option] name[=value] ...
 alias [-p] [name[=value] ... ]                               logout [n]
 bg [job_spec ...]                                            mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [->
 bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u n>  popd [-n] [+N | -N]
 break [n]                                                    printf [-v var] format [arguments]
 builtin [shell-builtin [arg ...]]                            pushd [-n] [+N | -N | dir]
 caller [expr]                                                pwd [-LP]
 case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac>   read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [>
 cd [-L|[-P [-e]] [-@]] [dir]                                 readarray [-n count] [-O origin] [-s count] [-t] [-u fd] >
 command [-pVv] command [arg ...]                             readonly [-aAf] [name[=value] ...] or readonly -p
 compgen [-abcdefgjksuv] [-o option]  [-A action] [-G globp>  return [n]
 complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A actio>  select NAME [in WORDS ... ;] do COMMANDS; done
 compopt [-o|+o option] [-DE] [name ...]                      set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
 continue [n]                                                 shift [n]
 coproc [NAME] command [redirections]                         shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFgilnrtux] [-p] [name[=value] ...]              source filename [arguments]
 dirs [-clpv] [+N] [-N]                                       suspend [-f]
 disown [-h] [-ar] [jobspec ...]                              test [expr]
 echo [-neE] [arg ...]                                        time [-p] pipeline
 enable [-a] [-dnps] [-f filename] [name ...]                 times
 eval [arg ...]                                               trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command [arguments ...]] [redirectio>  true
 exit [n]                                                     type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] or export -p                 typeset [-aAfFgilrtux] [-p] name[=value] ...
 false                                                        ulimit [-SHabcdefilmnpqrstuvxT] [limit]
 fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [co>  umask [-p] [-S] [mode]
 fg [job_spec]                                                unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; done                 unset [-f] [-v] [-n] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS; done                until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () { COMMANDS ; }       variables - Names and meanings of some shell variables
 getopts optstring name [arg]                                 wait [-n] [id ...]
 hash [-lr] [-p pathname] [-dt] [name ...]                    while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                                    { COMMANDS ; }

查詢 help 怎麼使用

執行

 $ help help

顯示

 help: help [-dms] [pattern ...]
    Display information about builtin commands.

    Displays brief summaries of builtin commands.  If PATTERN is
    specified, gives detailed help on all commands matching PATTERN,
    otherwise the list of help topics is printed.

    Options:
      -d        output short description for each topic
      -m        display usage in pseudo-manpage format
      -s        output only a short usage synopsis for each topic matching
        PATTERN

    Arguments:
      PATTERN   Pattern specifiying a help topic

    Exit Status:
    Returns success unless PATTERN is not found or an invalid option is given.

執行

$ help -d help

顯示

help - Display information about builtin commands.

執行

$ help -m help

顯示

NAME
    help - Display information about builtin commands.

SYNOPSIS
    help [-dms] [pattern ...]

DESCRIPTION
    Display information about builtin commands.

    Displays brief summaries of builtin commands.  If PATTERN is
    specified, gives detailed help on all commands matching PATTERN,
    otherwise the list of help topics is printed.

    Options:
      -d        output short description for each topic
      -m        display usage in pseudo-manpage format
      -s        output only a short usage synopsis for each topic matching
        PATTERN

    Arguments:
      PATTERN   Pattern specifiying a help topic

    Exit Status:
    Returns success unless PATTERN is not found or an invalid option is given.

SEE ALSO
    bash(1)

IMPLEMENTATION
    GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

執行

$ help -s help

顯示

help: help [-dms] [pattern ...]

以查詢「if」怎麼使用為例

執行

$ help if

顯示

if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
    Execute commands based on conditional.

    The `if COMMANDS' list is executed.  If its exit status is zero, then the
    `then COMMANDS' list is executed.  Otherwise, each `elif COMMANDS' list is
    executed in turn, and if its exit status is zero, the corresponding
    `then COMMANDS' list is executed and the if command completes.  Otherwise,
    the `else COMMANDS' list is executed, if present.  The exit status of the
    entire construct is the exit status of the last command executed, or zero
    if no condition tested true.

    Exit Status:
    Returns the status of the last command executed.

執行

$ help -d if

顯示

if - Execute commands based on conditional.

執行

$ help -m if

顯示

NAME
    if - Execute commands based on conditional.

SYNOPSIS
    if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi

DESCRIPTION
    Execute commands based on conditional.

    The `if COMMANDS' list is executed.  If its exit status is zero, then the
    `then COMMANDS' list is executed.  Otherwise, each `elif COMMANDS' list is
    executed in turn, and if its exit status is zero, the corresponding
    `then COMMANDS' list is executed and the if command completes.  Otherwise,
    the `else COMMANDS' list is executed, if present.  The exit status of the
    entire construct is the exit status of the last command executed, or zero
    if no condition tested true.

    Exit Status:
    Returns the status of the last command executed.

SEE ALSO
    bash(1)

IMPLEMENTATION
    GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

執行

$ help -s if

顯示

if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi

type 使用範例

執行

$ help type

顯示

type: type [-afptP] name [name ...]
    Display information about command type.

    For each NAME, indicate how it would be interpreted if used as a
    command name.

    Options:
      -a        display all locations containing an executable named NAME;
        includes aliases, builtins, and functions, if and only if
        the `-p' option is not also used
      -f        suppress shell function lookup
      -P        force a PATH search for each NAME, even if it is an alias,
        builtin, or function, and returns the name of the disk file
        that would be executed
      -p        returns either the name of the disk file that would be executed,
        or nothing if `type -t NAME' would not return `file'.
      -t        output a single word which is one of `alias', `keyword',
        `function', `builtin', `file' or `', if NAME is an alias, shell
        reserved word, shell function, shell builtin, disk file, or not
        found, respectively

    Arguments:
      NAME      Command name to be interpreted.

    Exit Status:
    Returns success if all of the NAMEs are found; fails if any are not found.

執行

$ type help

顯示

$ help is a shell builtin

執行

$ type if

顯示

$ if is a shell keyword

執行

$ type type

顯示

type is a shell builtin

執行

$ type ls

顯示

ls is aliased to `ls --color=auto'

執行

$ type -a ls

顯示

ls is aliased to `ls --color=auto'
ls is /bin/ls

command 的使用範例

執行

$ help command

顯示

command: command [-pVv] command [arg ...]
    Execute a simple command or display information about commands.

    Runs COMMAND with ARGS suppressing  shell function lookup, or display
    information about the specified COMMANDs.  Can be used to invoke commands
    on disk when a function with the same name exists.

    Options:
      -p        use a default value for PATH that is guaranteed to find all of
        the standard utilities
      -v        print a description of COMMAND similar to the `type' builtin
      -V        print a more verbose description of each COMMAND

    Exit Status:
    Returns exit status of COMMAND, or failure if COMMAND is not found.

或是查詢 $ man command

$ command -v ls

顯示

alias ls='ls --color=auto'