我对这些运算符在 bash 中使用时有何不同(括号、双括号、括号和双括号)感到有些困惑。
[[ , [ , ( , ((
Run Code Online (Sandbox Code Playgroud)
我见过人们在这样的 if 语句中使用它们:
if [[condition]]
if [condition]
if ((condition))
if (condition)
Run Code Online (Sandbox Code Playgroud) 根据我的阅读,将命令放在括号中应该在子shell 中运行它,类似于运行脚本。如果这是真的,如果 x 未导出,它如何查看变量 x?
x=1
Run Code Online (Sandbox Code Playgroud)
(echo $x)在命令行上运行结果为 1
echo $x正如预期的那样,在脚本中运行不会产生任何结果