日期:2014-05-16  浏览次数:20638 次

我使用过的Linux命令之help - 显示Bash内建命令的帮助信息

我使用过的Linux命令之help - 显示Bash内建命令的帮助信息

本文链接:http://codingstandards.iteye.com/blog/804620 ? (转载请注明出处)

用途说明

help命令顾名思义就是显示帮助信息的,它是个Bash内建命令,也只是用来显示Bash内建命令的帮助信息的(Display? helpful? information about builtin commands)。如果要显示外部命令的帮助信息,可以使用man命令或者info命令。在使用Linux或Unix系统时,我们始终要记住,所有的命令几乎都可以在系统中找到帮助信息,而通过互联网找来的信息只是帮助你迅速入门,而且英文版的资料比中文版的资料可能更靠谱一些,本文也不例外。

常用参数

help命令如果不带任何参数,则显示Bash常用内建命令的列表。

格式:help

help命令如果跟上命令名称,则显示此命令的详细帮助信息。

格式:help COMMAND

如果只想显示简单的帮助信息,加上-s即可。

格式:help -s COMMAND

?

使用示例

示例一 显示内建命令列表

[root@web ~]# type -a help
help is a shell builtin????? <== 表明help是内建命令
[root@web ~]# help
GNU bash, version 3.2.25(1)-release (i686-redhat-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 [&]?????????????????????? (( expression ))
?. filename [arguments]???????????? :
?[ arg... ]???????????????????????? [[ expression ]]
?alias [-p] [name[=value] ... ]???? bg [job_spec ...]
?bind [-lpvsPVS] [-m keymap] [-f fi break [n]
?builtin [shell-builtin [arg ...]]? caller [EXPR]
?case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]
?command [-pVv] command [arg ...]?? compgen [-abcdefgjksuv] [-o option
?complete [-abcdefgjksuv] [-pr] [-o continue [n]
?declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]
?disown [-h] [-ar] [jobspec ...]??? echo [-neE] [arg ...]
?enable [-pnds] [-a] [-f filename]? eval [arg ...]
?exec [-cl] [-a name] file [redirec exit [n]
?export [-nf] [name[=value] ...] or false
?fc [-e ename] [-nlr] [first] [last fg [job_spec]
?for NAME [in WORDS ... ;] do COMMA for (( exp1; exp2; exp3 )); do COM
?function NAME { COMMANDS ; } or NA getopts optstring name [arg]
?hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...]
?history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif
?jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si
?let arg [arg ...]????????????????? local name[=value] ...
?logout???????????????????????????? popd [+N | -N] [-n]
?printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]
?pwd [-LP]????????????????????????? read [-ers] [-u fd] [-t timeout] [
?readonly [-af] [name[=value] ...]? return [n]
?select NAME [in WORDS ... ;] do CO set [--abefhkmnptuvxBCHP] [-o opti
?shift [n]????????????????????????? shopt [-pqsu] [-o long-option] opt
?source filename [arguments]??????? suspend [-f]
?test [expr]??????????????????????? time [-p] PIPELINE
?times????????????????????????????? trap [-lp] [arg signal_spec ...]
?true?????????????????????????????? type [-afptP] name [name ...]
?typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit
?umask [-p] [-S] [mode]???????????? unalias [-a] name [name ...]
?unset [-f] [-v] [name ...]???????? until COMMANDS; do COMMANDS; done
?variables - Some variable names an wait [n]
?while COMMANDS; do COMMANDS; done? { COMMANDS ; }
[root@web ~]# help help
help: help [-s] [pattern ...]
??? Display helpful information about builtin commands.? If PATTERN is
??? specified, gives detailed help on all commands matching PATTERN,
??? otherwise a list of the builtins is printed.? The -s option
??? restricts the output for each builtin command matching PATTERN to
??? a short usag