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?

Usul
  • 445
user93236
  • 391

2 Answers2

44

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.

Anto
  • 771
Usul
  • 445
  • 6
    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 08 '18 at 16:20
15

& 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