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
  • 425
  • 3
  • 5
user93236
  • 391
  • 1
  • 3
  • 6

2 Answers2

42

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
  • 2
  • 6
  • 13
Usul
  • 425
  • 3
  • 5
  • 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 08 '18 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

Sepahrad Salour
  • 2,629
  • 3
  • 20
  • 27