Mayerz Mayerz - 1 month ago 6
Bash Question

syntax error near unexpected token `>' when using '&>>' redirection operator

At the beggining of my file I redirect stderr to stdout, and stdout to logfile, quick and lazy way to log everything printed.

During my script, some commands have large/unused output and I want to redirect them to my logfile without their output showing on stdout.

I tried to use

/etc/init.d/myservice stop &>> file.log
, but always ending up with the error "... syntax error near unexpected token `>'"

Bash version is 3.2.25(1)-release


That syntax wasn't introduced until bash 4. You can do the same thing though with

/etc/init.d/myservice stop >> file.log 2>&1

as noted here