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
相關文章
相關標籤/搜索