您的位置:首页 > 运维架构 > Linux

每天一个linux命令

2016-06-17 00:37 453 查看
   BASH_BUILTINS(1)

---该翻译只是出于爱好!
NAME

       bash,  :,  .,  [,  alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts, hash, help, history,  jobs, kill, let, local, logout,
mapfile, popd, printf, pushd, pwd, read, readonly, return, set,shift, shopt, source, suspend, test, times, trap, true, type, typeset,  ulimit,  umask,  unalias,  unset,wait - bash built-in commands, see bash(1)
名字

bash,  :,  .,  [,  alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts,
hash, help,history,  jobs, kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set,shift, shopt, source, suspend, test, times, trap, true, type, typeset,  ulimit,  umask,  unalias,  unset,wait
-bash buit-in命令, 看bash(1)

BASH BUILTIN COMMANDS

       Unless otherwise noted, each builtin command documented in this section

       as accepting options preceded by - accepts -- to signify the end of the

       options.   The  :, true, false, and test builtins do not accept options

       and do not treat -- specially.  The exit, logout, break, continue, let,

       and  shift builtins accept and process arguments beginning with - with-

       out requiring --.  Other builtins that accept  arguments  but  are  not

       specified  as accepting options interpret arguments beginning with - as

       invalid options and require -- to prevent this interpretation.

       : [arguments]

              No effect; the command does nothing beyond  expanding  arguments

              and  performing any specified redirections.  A zero exit code is

              returned.

bash用户命令

除非有另外特别说明,每个用户命令只有一个选项,接受,这是唯一的选项。针对 :, true, false, and test 唯一接受,没有特别对待。针对 exit, logout, break, continue, let和shift只有接受,其过程的起始不需要关注。 其它用户命令进行解释说明,但没有对原理进行解释,不存在无效的操作和要求--对此前提进行解释说明。

:【参数】

无影响,这些命令不会进行扩展讨论和重新定义,返回0退出代码。

  source filename [arguments]

              Read and execute commands from filename  in  the  current  shell

              environment  and return the exit status of the last command exe-

              cuted from filename.  If filename does not contain a slash, file

              names  in  PATH  are used to find the directory containing file-

              name.  The file searched for in PATH  need  not  be  executable.

              When  bash  is  not  in  posix  mode,  the  current directory is

              searched if no file is found in PATH.  If the sourcepath  option

              to  the  shopt  builtin  command  is turned off, the PATH is not

              searched.  If any arguments are supplied, they become the  posi-

              tional  parameters  when  filename  is  executed.  Otherwise the

              positional parameters are unchanged.  The return status  is  the

              status  of  the  last  command exited within the script (0 if no

              commands are executed), and false if filename is  not  found  or

              cannot be read.

源文件【参数】

在当前shell环境中读取执行都来自该文件名,在最后一行执行命令即可退出该文件。如果文件名不包含在slash,文件会在PATH的引用路径中寻找。当文件在posix模式时,文件将不会在PATH中查找到而执行,因为当前目录没有在PATH中被找到。

如果源路径的选项在用户命令设置中被关闭,那么路径也不会被找到。提供的任何参数,在使用正确参数时将会被执行。参数的位置不改变。返回的状态将会在脚本的最后一个命令呈现(命令没有被执行将返回0),错误文件将不会找到或被读取。

       alias [-p] [name[=value] ...]

              Alias with no arguments or with the -p option prints the list of

              aliases in the form alias name=value on standard  output.   When

              arguments  are supplied, an alias is defined for each name whose

              value is given.  A trailing space in  value causes the next word

              to be checked for alias substitution when the alias is expanded.

              For each name in the argument list for which no  value  is  sup-

              plied,  the  name  and  value  of  the  alias is printed.  Alias

              returns true unless a name is given for which no alias has  been

              defined.

别名 [-p][名字[=值]...]

别名不带参数或是别名的名字=值作为标准输出带一个-p参数打印一系列的别名。当参数被支持,每一个别名的赋值将被识别。当一个别名被扩展,一个空格的值在下一个被检查的词将被替换。对于每个名字的参数其值都是被支持的,别名的名字和值都是被打印的。一个别名没有别定义那么别名的返回值为真。

 bg [jobspec ...]

              Resume  each  suspended  job jobspec in the background, as if it

              had been started with &.  If jobspec is not present, the shell’s

              notion  of the current job is used.  bg jobspec returns 0 unless

              run when job control is disabled or, when run with  job  control

              enabled,  any  specified  jobspec  was  not found or was started

              without job control.

bg[jobspec...]

在后台继续执行工作,要添加&。如果jobspec不在当前工作,shell的外壳将被使用。当作业被取消控制bg的jobspec将返回0除非它在跑,等作业可控,任何的特别的jobspec将不被开始或者作业不受控制。

bind [-m keymap] [-lpsvPSV]

       bind [-m keymap] [-q function] [-u function] [-r keyseq]

       bind [-m keymap] -f filename

       bind [-m keymap] -x keyseq:shell-command

       bind [-m keymap] keyseq:function-name

       bind rea
4000
dline-command

              Display current readline key and function bindings, bind  a  key

              sequence  to  a  readline  function  or macro, or set a readline

              variable.  Each non-option argument is a  command  as  it  would

              appear  in  .inputrc, but each binding or command must be passed

              as a separate argument; e.g.,  ’"\C-x\C-r":  re-read-init-file’.

              Options, if supplied, have the following meanings:

              -m keymap

 Use keymap as the keymap to be affected by the subsequent

                     bindings.  Acceptable keymap names are emacs, emacs-stan-

                     dard,  emacs-meta,  emacs-ctlx,  vi, vi-move, vi-command,

                     and vi-insert.  vi is equivalent to vi-command; emacs  is

                     equivalent to emacs-standard.

bind [-b 按键配置] [-lpsvPSV]
bind [-m 按键配置] [-q 功能] [-u 功能] [-r 键盘]
bind [-m keymap] -f 文件名字
bind [-m keymap] -x keyseq:shell命令
bind [-m keymap] keyseq:功能名字
bind 编辑名字
显示当前的编辑的键值和功能联系,连续的键值进行编辑功能和宏,或者设置编辑变量。每个非参数就会出现。inputrc,但每个绑定或命令一定作为分离的参数;例如“ ’"\C-x\C-r":  re-read-init-file’选项,如果支持,后面添加:
-m keymap
将快捷键作为kepmap使用会影响后续使用,可使用的keymap名字是emacs,emacs-stan-dard,emacs-meta,emacs-ctlx,vi,vi-move,vi-command,和vi-insert。iv相当于vi-command;emacs相当与emac-standard

-l     List the names of all readline functions.

              -p     Display  readline  function  names and bindings in such a

                     way that they can be re-read.

              -P     List current readline function names and bindings.

              -s     Display readline key sequences bound to  macros  and  the

                     strings  they  output  in such a way that they can be re-

                     read.

              -S     Display readline key sequences bound to  macros  and  the

                     strings they output.

-l 列出所有编辑函数的名字。
-p 重新读取显示编辑函数和绑定的方式
-s 重新读取显示编辑序列组成宏和字符串可以被输出
-S 显示编辑序列组成的宏和字符串

-v     Display  readline variable names and values in such a way

                     that they can be re-read.

              -V     List current readline variable names and values.

              -f filename

                     Read key bindings from filename.

              -q function

                     Query about which keys invoke the named function.

              -u function

                     Unbind all keys bound to the named function.

              -r keyseq

                     Remove any current binding for keyseq.

-v 重读显示编辑变量名和值
-V 列出当前编辑变量名和值
-f 文件名
从文件名中读取绑定的关键词
-q 函数
查询指定关键字的函数名字
-u 函数
所有不绑定快捷键的函数名字
-r 键盘点击
重新剪切当前绑定的keyseq
 -x keyseq:shell-command

                     Cause shell-command to be  executed  whenever  keyseq  is

                     entered.   When shell-command is executed, the shell sets

                     the READLINE_LINE variable to the contents of  the  read-

                     line  line  buffer and the READLINE_POINT variable to the

                     current location of the insertion point.  If the executed

                     command  changes  the  value  of  READLINE_LINE  or READ-

                     LINE_POINT, those new values will  be  reflected  in  the

                     editing state.

              The  return value is 0 unless an unrecognized option is given or

              an error occurred.

-x 按键:shell命令

无论什么时候按键组合都会在shell命令中参与。当shell命令被执行 是,shell

设置的编辑模式变量就会包含在编辑模式缓存中和编辑操作变量停留在当前编辑点。如果编辑命令改变编辑模式的值或编辑方式,他们新的变量将会影响编辑状态。

一个不识别的操作或错误的占用返回值为0。

 break

              Exit from within a for, while, until, or select loop.  If  n  is

              specified, break n levels.  n must be ≥ 1.  If n is greater than

              the number of enclosing loops, all enclosing loops  are  exited.

              The  return  value  is  non-zero when n is ≤ 0; Otherwise, break

              returns 0 value.

终断

退出for,while,until,或select循环方式。n是特定的层,是第几层就退出第几层。n一定大于1.如果n大于封闭值时,所有的封闭数都退出循环。当n小于等于0时,返回值为非零。否则终端返回0值。

builtin shell-builtin [arguments]

              Execute the specified shell builtin, passing it  arguments,  and

              return its exit status.  This is useful when defining a function

              whose name is the same as a shell builtin, retaining  the  func-

              tionality of the builtin within the function.  The cd builtin is

              commonly redefined this way.  The  return  status  is  false  if

              shell-builtin is not a shell builtin command.

builtin shell-builtin [参数]

执行指定的shell builtin,传递参数,返回退出状态。定义一个函数名是由相同的shell builtin,相同的功能函数组成是很有用的。cd builtin是一般重定义的方式。如果shell-builtin返回状态不是builtin命令,则返回状态为false。

 caller [expr]

              Returns the context of any active subroutine call (a shell func-

              tion or a script executed with the . or source builtins.   With-

              out expr, caller displays the line number and source filename of

              the current subroutine call.  If a non-negative integer is  sup-

              plied as expr, caller displays the line number, subroutine name,

              and source file corresponding to that position  in  the  current

              execution  call  stack.  This extra information may be used, for

              example, to print a stack trace.  The current frame is frame  0.

              The  return  value is 0 unless the shell is not executing a sub-

              routine call or expr does not correspond to a valid position  in

              the call stack

caller [表达式]

返回当前子程序shell函数括号里的文本或脚本执行的.或源内容。没有表达式,caller显示行数和当前响应的子程序的源文件名。如果一个非整数作为表达式,caller显示行名,程序名和源文件相当于执行的栈堆。当前帧为0帧。如果shell没有执行程序进程或表达式不等于有效位置的进程栈就返回0.

.

cd [-L|-P] [dir]

              Change  the  current directory to dir.  The variable HOME is the

              default dir.  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  in

              CDPATH  is  the  same as the current directory, i.e., ‘‘.’’.  If

              dir begins with a slash (/), then CDPATH is  not  used.  The  -P

              option  says  to use the physical directory structure instead of

              following symbolic links (see also the  -P  option  to  the  set

              builtin command); the -L option forces symbolic links to be fol-

              lowed.  An argument of - is equivalent to $OLDPWD.   If  a  non-

              empty  directory  name from CDPATH is used, or if - is the first

              argument, and the directory change is successful,  the  absolute

              pathname of the new working directory is written to the standard

              output.  The return value is true if the directory was  success-

              fully changed; false otherwise.

cd [-L|-P]显示文件列表

改变当前目录成为显示文件列表。家变量是默认显示文件列表。变量CDPATH规定搜索的目录包含显示文件列表。在CDPATH中代替的目录名被冒号分离。一个空的目录在CDPATH和当前目录相同。例如:“.” .如果显示的文件列表是以/,那CDPATH不可以用。-P 的选项说使用物理目录结构代替符号链接(请参照-P选项设置的builtin命令)-L选项是强制链接。- 的参数相当于回到老的当前路径,或-是第一个参数,目录将成功切换,新的正工作目录的绝对路径名被标准输出。如果一个目录成功改变返回值为真,反之亦然。

command [-pVv] command [arg ...]

              Run  command  with  args  suppressing  the normal shell function

              lookup. Only builtin commands or commands found in the PATH  are

              executed.   If the -p option is given, the search for command is

              performed using a default value for PATH that is  guaranteed  to

              find  all  of  the  standard  utilities.  If either the -V or -v

              option is supplied, a description of command is printed.  The -v

              option  causes a single word indicating the command or file name

              used to invoke command to be displayed; the -V option produces a

              more  verbose  description.  If the -V or -v option is supplied,

              the exit status is 0 if command was found, and  1  if  not.   If

              neither option is supplied and an error occurred or command can-

              not be found, the exit status is 127.  Otherwise, the exit  sta-

              tus of the command builtin is the exit status of command.

命令 [-pVv] 命令[参数...]

运行带参数的命令抑制正常shell函数的查找。仅在PATH中builtin命令或函数命令被执行。如果被赋予-p选项,标准公共事业是采用默认的值PATH中搜索默认的命令。如果-V或-v选项被提供,一个描述命令的操作将被打印。-v的操作是一个指令性命令或文件名被调用显示;-v会产生一个冗余的描述。一个-V或-v选项被支持,命令被找到返回状态为0,返回1则相反。如果选项被支持并错误占用或命令没有被找到,返回状态为127.否则,返回状态命令是返回状态存在。

compgen [option] [word]

              Generate  possible  completion matches for word according to the

              options, which may  be  any  option  accepted  by  the  complete

              builtin  with  the exception of -p and -r, and write the matches

              to the standard output.  When using the -F or  -C  options,  the

              various  shell  variables  set  by  the  programmable completion

              facilities, while available, will not have useful values.

              The matches will be generated in the same way  as  if  the  pro-

              grammable  completion  code  had  generated them directly from a

              completion specification with the same flags.  If word is speci-

     
b421
        fied, only those completions matching word will be displayed.

              The  return  value is true unless an invalid option is supplied,

              or no matches were generated.

补齐命令 [选项][单词]

根据选项一般完成形成匹配的词,出来-p和-r,任何的选项都可以被执行,标准输出匹配的词。正使用-F或-C选项,各种shell变量是被赋予可编程的工具,当被使用是,将变得没有用。

在相同方式中匹配被形成就好像是完成的程序代码有自己的规格标准。如果一个词被规范,唯一匹配的词将不显示。

有效的选项被提供,返回为真,或匹配不形成

complete [-abcdefgjksuv] [-o comp-option] [-DE] [-A action]  [-G  glob-

       pat] [-W wordlist] [-F function] [-C command]

              [-X filterpat] [-P prefix] [-S suffix] name [name ...]

       complete -pr [-DE] [name ...]

              Specify how arguments to each name should be completed.  If  the

              -p  option  is supplied, or if no options are supplied, existing

              completion specifications are printed in a way that allows  them

              to be reused as input.  The -r option removes a completion spec-

              ification for each name, or, if no names are supplied, all  com-

              pletion  specifications.   The  -D  option  indicates  that  the

              remaining options and actions should apply  to  the  ‘‘default’’

              command  completion;  that is, completion attempted on a command

              for which no completion has previously  been  defined.   The  -E

              option  indicates  that the remaining options and actions should

              apply to  ‘‘empty’’  command  completion;  that  is,  completion

              attempted on a blank line.

              The  process  of  applying  these completion specifications when

              word completion is  attempted  is  described  above  under  Pro-

              grammable Completion.

 Other  options,  if specified, have the following meanings.  The
              arguments to the -G, -W, and -X options (and, if necessary,  the
              -P  and -S options) should be quoted to protect them from expansion before the complete builtin is invoked.
              -o comp-option

the comp-option controls several aspects  of  the  compspec’s  behavior beyond the simple generation of completions.  comp-option may be one of:

                      bashdefault

                              Perform the rest of the default bash completions

                             if the compspec generates no matches.

 dirnames

                              Perform directory name completion if  the  compspec generates no matches.

 filenames

                              Tell  readline that the compspec generates filenames, so it can perform  any  filename-specific processing  (like  adding  a  slash to directory names, quoting special characters, or  suppressing  trailing spaces).  Intended to
be used with shell functions.

 nospace 

Tell  readline  not  to  append  a  space   (the default)  to  words  completed at the end of the line.

完成 [-abcdefgjksuv] [-o 比较选项][-DE] [-A 功能] [-G  globpat] [-W词表] [-F 函数] [-C
命令] [-X过滤板] [-P前缀] [-S 后缀] name [名字 ...]

complete -pr [-DE] [name ...]

     指定每个名字实现的参数。如果-p选项被支持,或如果选项操作不支持,在某种程度上存在的完成配置重复打印输出。-r每个名字选项进行配置的删除,或,如果名字不匹配,完成所有的配置。-D 选项表示剩余的选项和行为应该应用“default”命令实现。就是,为完成的命令中之前没有定义的不被完成。 -E 选项定义剩余的操作和行为应被赋予“empty“命令实现;即,未完成显示空白行。

当单词同步未实现是描述在程序完成下时,进程应用于配置文件。其它选项,如果是配置有如下配置。在完整内部调用中,参数-G,-W和-X选项(如果有必要,用-P和-S选项)应该被引用都工程阻止被扩大。多个匹配的操作在几个指定的操作命令行为后面是简单的匹配补充。多个匹配命令可能为其中之一:基本默认,完成执行剩余默认的命令如果指定路径没有生成。

文件夹名

执行目录完成如果指定目录路径产生不匹配。

文件名

告诉当前解读器指定目录一般的文件名,所以它执行完处理文件名具体的名字(像加斜杠到文件目录名后面,引用关键字,或完成末尾空格)用于shell函数。

没空格

告诉编辑器没有完成单词不用追加空格在最后一行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: