首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

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

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

我使用过的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 usage synopsis.
[root@web ~]# help -s help
help: help [-s] [pattern ...]
[root@web ~]#

示例二 非内建命令的帮助信息

[root@web ~]# help error
-bash: help: no help topics match `error'.? Try `help help' or `man -k error' or `info error'.
[root@web ~]# help ls
-bash: help: no help topics match `ls'.? Try `help help' or `man -k ls' or `info ls'.
[root@web ~]# man ls

示例三 一些常用内建命令的帮助信息

[root@web ~]# help cd
cd: cd [-L|-P] [dir]
??? Change the current directory to DIR.? The variable $HOME is the
??? default DIR.? The variable CDPATH defines the search path for
??? the directory containing DIR.? Alternative directory names in CDPATH
??? are separated by a colon (:).? A null directory name is the same as
??? the current directory, i.e. `.'.? If DIR begins with a slash (/),
??? then CDPATH is not used.? If the directory is not found, and the
??? shell option `cdable_vars' is set, then try the word as a variable
??? name.? If that variable has a value, then cd to the value of that
??? variable.? The -P option says to use the physical directory structure
??? instead of following symbolic links; the -L option forces symbolic links
??? to be followed.
[root@web ~]# help pwd
pwd: pwd [-LP]
??? Print the current working directory.? With the -P option, pwd prints
??? the physical directory, without any symbolic links; the -L option
??? makes pwd follow symbolic links.
[root@web ~]# help if
if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
??? 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.
[root@web ~]# help for
for: for NAME [in WORDS ... ;] do COMMANDS; done
??? The `for' loop executes a sequence of commands for each member in a
??? list of items.? If `in WORDS ...;' is not present, then `in "$@"' is
??? assumed.? For each element in WORDS, NAME is set to that element, and
??? the COMMANDS are executed.
for ((: for (( exp1; exp2; exp3 )); do COMMANDS; done
??? Equivalent to
??????? (( EXP1 ))
??????? while (( EXP2 )); do
??????????????? COMMANDS
??????????????? (( EXP3 ))
??????? done
??? EXP1, EXP2, and EXP3 are arithmetic expressions.? If any expression is
??? omitted, it behaves as if it evaluates to 1.
[root@web ~]# help while
while: while COMMANDS; do COMMANDS; done
??? Expand and execute COMMANDS as long as the final command in the
??? `while' COMMANDS has an exit status of zero.
[root@web ~]# help case
case: case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac
??? Selectively execute COMMANDS based upon WORD matching PATTERN.? The
??? `|' is used to separate multiple patterns.
[root@web ~]# help echo
echo: echo [-neE] [arg ...]
??? Output the ARGs.? If -n is specified, the trailing newline is
??? suppressed.? If the -e option is given, interpretation of the
??? following backslash-escaped characters is turned on:
??????? \a????? alert (bell)
??????? \b????? backspace
??????? \c????? suppress trailing newline
??????? \E????? escape character
??????? \f????? form feed
??????? \n????? new line
??????? \r????? carriage return
??????? \t????? horizontal tab
??????? \v????? vertical tab
??????? \\????? backslash
??????? \0nnn?? the character whose ASCII code is NNN (octal).? NNN can be
??????????????? 0 to 3 octal digits
???
??? You can explicitly turn off the interpretation of the above characters
??? with the -E option.
[root@web ~]#

问题思考相关资料

【1】Beyond the Code 10条捷径掌握bash

?

返回 我使用过的Linux命令系列总目录

?

热点排行