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

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

常用参数:

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

参考示例

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

[root@linux-arae-cc ~]# 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@linux-arae-cc ~]# help -s cd
cd: cd [-L|[-P [-e]] [-@]] [dir]

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

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

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

[root@linux-arae-cc ~]# 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.
………………省略部分输出信息………………