I'm writing a shell script for Mac OS/Linux. The script is run by a cron job. I'm trying to append stdout and stderr to a log file. My command(simplified) looks like this(line 5 in myscript.sh
):
mycommand &>> log.txt
I get the following error:
myscript.sh: line 5: syntax error near unexpected token `>
However if I change the command to:
mycommand &> log.txt
I don't get any errors, but the file is overwritten (not appended).
Any idea why &>>
doesn't work but &>
works?