39

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

2 Answers 2

41

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
  • 4
    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, 2018 at 16:20
13

& 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.