Linux命令:help

语法

help: help [-dms] [模式 ...]
显示内建命令的相关信息。html

显示内建命令的简略信息。若是指定了 PATTERN 模式,给出全部匹配 PATTERN 模式的命令的详细帮助,不然打印一个帮助主题列表。linux

选项:
-d description。只打印每一个主题的功能的简要描述。
-m 以man样式打印帮助。
-s short。只打印语法部分。

shell

说明

通常咱们经常使用的是help跟一个命令,其实help能够用pattern来打印多个命令的用法。用法分两部分,一个是语法,一个含义或功能说明。分别用-s和-d表示。bash

help help

 1 help: help [-dms] [pattern ...]
 2     Display information about builtin commands.
 3 
 4     Displays brief summaries of builtin commands.  If PATTERN is
 5     specified, gives detailed help on all commands matching PATTERN,
 6     otherwise the list of help topics is printed.
 7 
 8     Options:
 9       -d        output short description for each topic
10       -m        display usage in pseudo-manpage format
11       -s        output only a short usage synopsis for each topic matching
12         PATTERN
13 
14     Arguments:
15       PATTERN   Pattern specifiying a help topic
16 
17     Exit Status:
18     Returns success unless PATTERN is not found or an invalid option is given.

 

举例

如下均以cd为例。less

只打印语法部分ui

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

只打印做用说明部分spa

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

模拟man样式打印code

 1 [root@gm ~]# help -m cd
 2 NAME
 3     cd - Change the shell working directory.
 4 
 5 SYNOPSIS
 6     cd [-L|[-P [-e]]] [dir]
 7 
 8 DESCRIPTION
 9     Change the shell working directory.
10 
11     Change the current directory to DIR.  The default DIR is the value of the
12     HOME shell variable.
13 
14     The variable CDPATH defines the search path for the directory containing
15     DIR.  Alternative directory names in CDPATH are separated by a colon (:).
16     A null directory name is the same as the current directory.  If DIR begins
17     with a slash (/), then CDPATH is not used.
18 
19     If the directory is not found, and the shell option `cdable_vars' is set,
20     the word is assumed to be  a variable name.  If that variable has a value,
21     its value is used for DIR.
22 
23     Options:
24         -L      force symbolic links to be followed
25         -P      use the physical directory structure without following symbolic
26         links
27         -e      if the -P option is supplied, and the current working directory
28         cannot be determined successfully, exit with a non-zero status
29 
30     The default is to follow symbolic links, as if `-L' were specified.
31 
32     Exit Status:
33     Returns 0 if the directory is changed, and if $PWD is set successfully when
34     -P is used; non-zero otherwise.
35 
36 SEE ALSO
37     bash(1)
38 
39 IMPLEMENTATION
40     GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
41     Copyright (C) 2011 Free Software Foundation, Inc.
42     License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

 

打印多个命令帮助。orm

1 [root@gm ~]# help -s read*
2 Shell commands matching keyword `read*'
3 
4 read: read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
5 readarray: readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
6 readonly: readonly [-aAf] [name[=value] ...] or readonly -p
相关文章
相关标签/搜索