为什么 echo test &>>file 在 OS X 上不起作用

why doesn't echo test &>>file work on OS X

我有一些在 ubuntu 盒子上制作的脚本,但这些在我的 OS X 上不起作用。

echo test &>>file
-bash: syntax error near unexpected token `>'

我的想法是,我想将 stdout 和 stderr 都放入一个文件中。

重定向运算符 &>> 出现在 Bash 版本 4 中。

使用 Bash 3.x(OSX 默认发货),您必须使用 等价形式 :

>>file 2>&1