1.shopt介绍
linux内建命令shopt允许shell在空闲时修改shell选项,它经常出现在启动文件中。但是,在一般脚本中也常出现,不过需要在版本2之后的bash中才支持。
2.样例
-->shopt用法
命令:
help shopt
[root@elasticsearch ~]# help shopt
shopt: shopt [-pqsu] [-o] [optname ...]
Set and unset shell options.
Change the setting of each shell option OPTNAME. Without any option
arguments, list all shell options with an indication of whether or not each
is set.
Options:
-o restrict OPTNAMEs to those defined for use with `set -o'
-p print each shell option with an indication of its status
-q suppress output
-s enable (set) each OPTNAME
-u disable (unset) each OPTNAME
Exit Status:
Returns success if OPTNAME is enabled; fails if an invalid option is
given or OPTNAME is disabled.
[root@elasticsearch ~]#
样例:
[root@elasticsearch ~]# shopt -s cdspell #设置使用cd命令时,允许产生少量的拼写错误
[root@e