14

This question already has an answer here:

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?

marked as duplicate by don_crissti, slm Nov 29 '14 at 16:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

17

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.

  • 2
    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
3

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