30

In a script I have inherited the output of one of our programs is put in to a file with:

program &>> result.txt

I have been reading in my book "Learning the bash shell" at home over the weekend, but cannot find what this means ( I know what >and >> mean ).

I am missing something obvious?

0
32

Your book is likely too old, this is something new in Bash version 4.

program &>> result.txt

is equivalent to

program >> result.txt 2>&1

Redirect and append both stdout and stderr to file result.txt. More about I/O redirection here.

1
  • 3
    Be careful with this syntax, running in anything other than bash (ie /bin/sh) then this backgrounds the process and then redirects to result.txt. Make sure /bin/bash is used – exussum Jan 8 '18 at 16:20
8

& means both standard output (1>) and standard error(2>).

>> means append to end of the file.

You can use 1>>a 2>&1 instead of &>>

Eg. date test >>file 2>&1

Not the answer you're looking for? Browse other questions tagged or ask your own question.