yae*_*ael -4 linux shell bash shell-script
我们有
bash -version
GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)
Run Code Online (Sandbox Code Playgroud)
以下 shell 选项的含义是什么(在 bash 脚本中)
shopt -s nullglob extglob
Run Code Online (Sandbox Code Playgroud)
取消它的相反方法是什么?
您使用shopt -uin取消设置 shell 选项bash。
shopt -u nullglob extglob
Run Code Online (Sandbox Code Playgroud)
将取消设置这两个选项。这在bash手册和help shopt交互式bashshell中进行了解释。
这里提到的具体选项在bash手册中有详细记录,但简而言之,它们是
nullglob:与任何文件名都不匹配的文件名通配模式只是扩展为空,而不是保持未扩展。
$ echo my*file
my*file
$ shopt -s nullglob
$ echo my*file
Run Code Online (Sandbox Code Playgroud)
(echo除了空行之外,最后没有输出)
extglob:启用扩展的通配符模式,例如,!(this|that)(将匹配 like*但不匹配任何名称为this或that)。
$ shopt -s extglob
$ touch this that theother
$ echo !(this|that)
theother
Run Code Online (Sandbox Code Playgroud)
bash手册中描述了各种类型的扩展通配模式。