内部命令和外部命令帮助

    查看内部命令和外部命令帮助

一、内部命令

  可以用type来判断该命令是内部命令还是外部命令,type后加要查看的命令.

示例写法:type enable

[10:52:18 root@centos ~]#type enable
enable is a shell builtin  

  有的命令既有内部命令也有外部命令但是系统会优先使用内部命令。
例如:type echo ,查看到的是内部命令,但是加上 -a系统会显示出他的外部命令路径。

[11:32:59 root@centos ~]#type echo
echo is a shell builtin
[11:33:18 root@centos ~]#type -a echo
echo is a shell builtin
echo is /usr/bin/echo  

help查看全部内部命令的简单说明

[09:47:49 root@centos ~]#help
GNU bash, version 4.2.46(2)-release (x86_64-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 [&]                               history [-c] [-d offset] [n] or history>
 (( expression ))                           if COMMANDS; then COMMANDS; [ elif COMM>
 . filename [arguments]                     jobs [-lnprs] [jobspec ...] or jobs -x >
 :                                          kill [-s sigspec | -n signum | -sigspec>
 [ arg... ]                                 let arg [arg ...]
 [[ expression ]]                           local [option] name[=value] ...
 alias [-p] [name[=value] ... ]             logout [n]
 bg [job_spec ...]                          mapfile [-n count] [-O origin] [-s coun>
 bind [-lpvsPVS] [-m keymap] [-f filename>  popd [-n] [+N | -N]
 break [n]                                  printf [-v var] format [arguments]
 builtin [shell-builtin [arg ...]]          pushd [-n] [+N | -N | dir]
 caller [expr]                              pwd [-LP]
 case WORD in [PATTERN [| PATTERN]...) CO>  read [-ers] [-a array] [-d delim] [-i t>
 cd [-L|[-P [-e]]] [dir]                    readarray [-n count] [-O origin] [-s co>
 command [-pVv] command [arg ...]           readonly [-aAf] [name[=value] ...] or r>
 compgen [-abcdefgjksuv] [-o option]  [-A>  return [n]
 complete [-abcdefgjksuv] [-pr] [-DE] [-o>  select NAME [in WORDS ... ;] do COMMAND>
 compopt [-o|+o option] [-DE] [name ...]    set [-abefhkmnptuvxBCHP] [-o option-nam>
 continue [n]                               shift [n]
 coproc [NAME] command [redirections]       shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFgilrtux] [-p] [name[=value>  source filename [arguments]
 dirs [-clpv] [+N] [-N]                     suspend [-f]
 disown [-h] [-ar] [jobspec ...]            test [expr]
 echo [-neE] [arg ...]                      time [-p] pipeline
 enable [-a] [-dnps] [-f filename] [name >  times
 eval [arg ...]                             trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command [arguments>  true
 exit [n]                                   type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] or expor>  typeset [-aAfFgilrtux] [-p] name[=value>
 false                                      ulimit [-SHacdefilmnpqrstuvx] [limit]
 fc [-e ename] [-lnr] [first] [last] or f>  umask [-p] [-S] [mode]
 fg [job_spec]                              unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; >  unset [-f] [-v] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS;>  until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () >  variables - Names and meanings of some >
 getopts optstring name [arg]               wait [id]
 hash [-lr] [-p pathname] [-dt] [name ...>  while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                  { COMMANDS ; }  

查看某一个内部命令详细说明:

示例写法:help enable
help后面加上要查看的命令。

[10:45:50 root@centos ~]#help enable
enable: enable [-a] [-dnps] [-f filename] [name ...]
    Enable and disable shell builtins.
    
    Enables and disables builtin shell commands.  Disabling allows you to
    execute a disk command which has the same name as a shell builtin
    without using a full pathname.
    
    Options:
      -a	print a list of builtins showing whether or not each is enabled
      -n	disable each NAME or display a list of disabled builtins
      -p	print the list of builtins in a reusable format
      -s	print only the names of Posix `special' builtins
    
    Options controlling dynamic loading:
      -f	Load builtin NAME from shared object FILENAME
      -d	Remove a builtin loaded with -f
    
    Without options, each NAME is enabled.
    
    To use the `test' found in $PATH instead of the shell builtin
    version, type `enable -n test'.
    
    Exit Status:
    Returns success unless NAME is not a shell builtin or an error occurs.  

echo用法及原理

echo可以将你输入的内容进行显示,可以加参数,显示参数标准输出显示。并且自动换新行。

-n: 加上-n就是不换行

-e:启用反斜杠转义解释 示例:echo -e 'a' 警报声 'a' 加引号。

  用法示例:sleep 10;echo -e 'a' 休眠10秒,结束后警报声提醒

-E:禁用反斜杠转义解释

范例:echo的help使用方法

echo内部命令帮助查看:
示例写法:help echo

[11:33:21 root@centos ~]#help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs on the standard output followed by a newline.
    
    Options:
      -n	do not append a newline
      -e	enable interpretation of the following backslash escapes
      -E	explicitly suppress interpretation of backslash escapes
    
    `echo' interprets the following backslash-escaped characters:
      a	alert (bell)  警报声提醒
      	backspace
      c	suppress further output 压缩之后的输出 压缩掉echo的换行
      e	escape character
      f	form feed
      
	new line  换新行  本身echo就带有换行,再加
表示换两行。
      
	carriage return
      		horizontal tab
      v	vertical tab
      \	backslash
      nnn	the character whose ASCII code is NNN (octal).  NNN can be
    	0 to 3 octal digits
      xHH	the eight-bit character whose value is HH (hexadecimal).  HH
    	can be one or two hex digits
    
    Exit Status:
    Returns success unless a write error occurs. 

二、外部命令

带有路径的都是外部命令。
示例:passwd --help

[13:55:39 root@centos ~]#type passwd
passwd is hashed (/usr/bin/passwd)  
[13:01:45 root@centos ~]#passwd --help
Usage: passwd [OPTION...] <accountName>
  -k, --keep-tokens       keep non-expired authentication tokens
  -d, --delete            delete the password for the named account (root only)
  -l, --lock              lock the password for the named account (root only)
  -u, --unlock            unlock the password for the named account (root only)
  -e, --expire            expire the password for the named account (root only)
  -f, --force             force operation
  -x, --maximum=DAYS      maximum password lifetime (root only)
  -n, --minimum=DAYS      minimum password lifetime (root only)
  -w, --warning=DAYS      number of days warning users receives before password
                          expiration (root only)
  -i, --inactive=DAYS     number of days after password expiration when an account
                          becomes disabled (root only)
  -S, --status            report password status on the named account (root only)
  --stdin                 read new tokens from stdin (root only)

Help options:
  -?, --help              Show this help message
  --usage                 Display brief usage message  

echo外部命令查看帮助:
示例写法:/bin/echo --help

[12:25:14 root@centos ~]#/bin/echo --help
Usage: /bin/echo [SHORT-OPTION]... [STRING]...
  or:  /bin/echo LONG-OPTION
Echo the STRING(s) to standard output.

  -n             do not output the trailing newline
  -e             enable interpretation of backslash escapes
  -E             disable interpretation of backslash escapes (default)
      --help     display this help and exit
      --version  output version information and exit

If -e is in effect, the following sequences are recognized:

  \      backslash
  a      alert (BEL)
        backspace
  c      produce no further output
  e      escape
  f      form feed
  
      new line
  
      carriage return
  	      horizontal tab
  v      vertical tab
  NNN   byte with octal value NNN (1 to 3 digits)
  xHH    byte with hexadecimal value HH (1 to 2 digits)

NOTE: your shell may have its own version of echo, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'echo invocation'  
(**echo**以上的写法查看到的帮助用法是相同的,但是帮助内容不一样,仅供参考。) ##    可能写的有点乱,第三次写还有点不适应。
原文地址:https://www.cnblogs.com/www233ii/p/11578042.html