gpt4 book ai didi

Bash:命令在子 shell 中用花括号分组

转载 作者:行者123 更新时间:2023-12-02 04:30:10 25 4
gpt4 key购买 nike

当我尝试这样的事情时:

( echo && { echo ; echo } )

我得到:

-bash: syntax error near unexpected token `)'

我确信我需要使用 subshel​​l。而且我确定我需要在其中进行分组。那么如何避免语法错误呢?提前致谢!

最佳答案

命令列表必须以 ; 或换行符结束。

而是说:

( echo && { echo ; echo ; } )
^^^
|======= Add this

来自 info bash:

   { list; }
list is simply executed in the current shell environment. list
must be terminated with a newline or semicolon. This is known
as a group command. ...

关于Bash:命令在子 shell 中用花括号分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23744909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com