Redirect STDERRto STDOUT:
script.sh >> temp.txt 2>&1
Or if bash4.0 is used :
$ script.sh &>> temp.txt
(Thanks for the second form, go to the comment. I cannot verify since I have the previous one bash.)
My tests were awesome:
$ time sleep 1 > /dev/null 2>&1
real 0m1.036s
user 0m0.002s
sys 0m0.032s
The problem is that redirection was included as part of the synchronization command. Here is the solution for this test:
$ (time sleep 1) > /dev/null 2>&1
, , , , .