当我尝试这样的事情时:
( echo && { echo ; echo } )
我得到了:
-bash: syntax error near unexpected token `)'
我确定我需要使用子shell。而且我确信我需要在其中进行分组。那么我该如何避免语法错误呢? 提前谢谢!
答案 0 :(得分:3)
命令列表必须以;
或换行符终止。
相反说:
( 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. ...