`

我使用过的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命令系列总目录

 

0
1
分享到:
评论

相关推荐

    cmd操作命令和linux命令大全收集

    ping -t -l 65550 ip 死亡之ping(发送大于64K的文件并一直ping就成了死亡之ping) ipconfig (winipcfg) 用于windows NT及XP(windows 95 98)查看本地ip地址,ipconfig可用参数“/all”显示全部配置信息 tlist -t 以...

    Linux简明教程.rar

    目的:让更多的人从零开始学会使用linux,少走弯路 演示系统:Ubuntu 10.04 desktop 适用人群:未接触或刚刚接触linux的同志们 本教程使用Ubuntu 10.04 LTS - Lucid Lynx做演示,其他版本皆大同小异,有特殊的相...

    Linux 命令入门文档.zip

    知道有些命令并不对应可执行文件,而是在 Bash 内置好的,此时可以使用 `help` 和 `help -d` 命令获取帮助信息。你可以用 `type 命令` 来判断这个命令到底是可执行文件、shell 内置命令还是别名。 - 学会使用 `&gt;` ...

    入门学习Linux常用必会60个命令实例详解doc/txt

    --help:显示此帮助信息并离开。 --version:显示版本信息并离开。 mount 1.作用 mount命令的作用是加载文件系统,它的用权限是超级用户或/etc/fstab中允许的使用者。 2.格式 mount -a [-fv] [-t ...

    附赠一套系统的linux教程:基础应用到服务搭建

    --help:显示命令帮助信息。 --version:显示命令版本信息。 示例: bash Copy code pwd pwd -L pwd -P 工作原理: pwd命令会返回你当前所在的目录的绝对路径。这个路径可以用来定位你在文件系统中的位置。 示例...

    magento2-db-code-backup-bash-script:Bash脚本

    Bash脚本:备份Magento2代码+数据库该实用程序脚本可帮助您备份Magento2代码和数据库。 您可以手动运行该命令,也可以通过cronjob自动执行该命令。安装您可以简单地下载脚本文件并授予可执行文件权限。 curl -0 ...

    列出所有Bash Shell内置命令的方法示例

    前言 Shell有很多内置在其源代码中的命令。这些命令是内置的,所以Shell不必到磁盘上搜索它们,执行速度因此加快。不同的Shell内置命令有所不同...你可以使用 help 命令查看 Bash 内置命令的信息。以下是几种不同类型的

    linux输入yum后提示: -bash: /usr/bin/yum: No such file or directory的解决方法

    在本篇文章里小编给大家整理的是关于linux输入yum后提示: -bash: /usr/bin/yum: No such file or directory的解决方法,有需要的朋友们参考下。

    linux shell 调试工具

    linux shell 调试工具 bash 可以设置断点、单步跟踪; 查看指令、变量值 等等 安装: tar -xvfz bashdb-5.0-1.1.2.tar.gz cd ./ bashdb-5.0-1.1.2 ./configuration make make install 使用: bashdb + 需要调试的脚本...

    Linux sed 命令用法详解

    Linux sed 命令 Linux sed 命令是利用脚本来处理文本文件。 sed 可依照脚本的指令来处理、编辑...-h或–help 显示帮助。 -n或–quiet或–silent 仅显示script处理后的结果。 -V或–version 显示版本信息。 动作说明:

    Linux 系统日常使用总结

    目录基本操作bash界面输入命令帮助命令关机重启标准文件架构文件操作set $PATH variable软件安装卸载Dpkg命令apt命令卸载软件软件源程序无响应 结束进程rar的解压出错 基本操作 bash界面 【nbcc@localhost~】$ ...

    git-and-linux-Commands:在git和ubuntu(linux)使用过程中通过示例获取特定操作,git概念,git错误及其修复的linux命令

    Git概念和Linux命令附有我在专案期间使用的范例和参考资料\回购开始: sudo apt-get install git git init本地文件夹的git功能git add . 将您的文件添加到进行分期git commit -m "comments"提交更改git remote add ...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 登陆服务器时输入 公帐号 openlab-open123 telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss 老师测评网址 http://172.16.0.198:8080/poll/ 各个 ...

    stc-isp:用于 Linux 的命令行 STC 8051 ISP 编程器

    用于 linux的 STC 8051 ISP 编程器有关更多信息,请使用 -h help 这是 gSTCISP 的一个 hack,我将 gtk(2.0) 版本转换为命令版本,也许有人正在寻找......试试这个工具...... 只是:做~ 限制: 1. 使用TTL转USB...

    An A-Z Index of the Linux Command LIne

    linux 命令一览表 alias Create an alias • apropos Search Help manual pages (man ­k) apt­get Search for and install software packages (Debian/Ubuntu) aptitude Search for and install software ...

    SimIt-ARM-3.0 ARM指令模拟器

    SimIt-ARM-3.0 给予命令行ARM指令模拟器,短小精悍,是研究ARM处理器的好工具,该模拟器既可以运行用户级别的ELF程序,又可以模拟运行Linux操作系统;提供了简单易用的调试命令,可以逐条跟踪指令的执行。 SimIt-...

    rsh:从CLI为Linux和Windows生成反向Shell

    产品特点使用此工具,您可以轻松地使用以下语言快速生成Linux和Windows支持的反向Shell命令: 重击Bash反向壳网猫网猫OpenBSD 非传统PythonIPv4 IPv6 RubyPerlPHP 电源外壳节点JS TCSH Awk Java用法usage: rsh [-h] ...

    pma:插件MAnager-VizalityPowercord的插件(很快的主题)管理器

    我该如何使用呢? 克隆仓库运行chmod + x pma 运行bash pma或./pma(请勿以root身份运行) 我们建议先运行./pma -d来配置目录。命令是什么? Usage: pma [OPTIONS]Options: -i --install Install powercord -l --...

    ipmi-wrapper:pxe 启动服务器时 ipmitool 的节省时间

    我只在 bash shell 下测试过,所以你可能需要这个。 用法 使用set-ipmi-pass.bash脚本将您的密码放入环境变量中: $ source ./set-ipmi-pass.bash Enter IPMI password: 然后你可以使用 ipmi 命令: ipmi ...

    v-z代表vim-Linux开发

    v-v代表vim V(1)用户命令V(1)名称v-z代表vim概要v [-a] [-c] [-l] [-[0-9]] [--debug] [- -help] [regex1 regex2 ... regexn]可用性bash,vim安装将v放在$ PATH的某个位置(例如/ usr / local / bin /)。 对于...

Global site tag (gtag.js) - Google Analytics