help命令的功能是用于显示帮助信息,能够输出Shell内部命令的帮助内容,但对于外部命令则无法使用,需要用man或info命令进行查看了。

语法格式:help[参数] 命令名

常用参数:

-d 显示命令的简短描述
-m 使用man手册格式显示帮助信息
-s 显示短格式的帮助信息

参考示例

以默认格式显示指定命令的帮助信息:

[root@linuxcool ~]# help cd
cd: cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.
Change the current directory to DIR.  The default DIR is the value of the
HOME shell variable.
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.  If DIR begins
with a slash (/), then CDPATH is not used.
………………省略部分输出信息………………

以短格式显示指定命令的帮助信息:

[root@linuxcool ~]# help -s cd
cd: cd [-L|[-P [-e]] [-@]] [dir]

以简短格式显示指定命令的帮助信息:

[root@linuxcool ~]# help -d cd
cd - Change the shell working directory.

以man命令格式显示指定命令的帮助信息:

[root@linuxcool ~]# help -m cd
NAME
cd - Change the shell working directory.
SYNOPSIS
cd [-L|[-P [-e]] [-@]] [dir]
DESCRIPTION
Change the shell working directory.
Change the current directory to DIR.  The default DIR is the value of the
HOME shell variable.
………………省略部分输出信息………………
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。