无法在Bash 4中启用globstar

Léo*_* 준영 8 bash bash4 shopt

我把以下内容写入我的.bashrc失败了

shopt -s globstar
Run Code Online (Sandbox Code Playgroud)

我正在尝试测试命令

ls **/*.c
Run Code Online (Sandbox Code Playgroud)

并通过比较它

ls */*/*.c
Run Code Online (Sandbox Code Playgroud)

如何在Bash 4中启用globstar?

Bri*_*ell 13

嗯.shopt -s globstar应该管用.

要进行调试,请确保您正在运行Bash 4:

$SHELL --version
Run Code Online (Sandbox Code Playgroud)

然后检查以下设置globstar:

shopt globstar
Run Code Online (Sandbox Code Playgroud)

如果未设置,请尝试手动设置:

shopt -s globstar
Run Code Online (Sandbox Code Playgroud)

现在看看是否有效.如果是这样,您可能想要了解为什么.bashrc不能正常工作.您是否记得在编辑之后重新启动shell .bashrc,或者加载它. .bashrc

  • 要禁用:`shopt -u globstar`. (2认同)