redirect stdout and stderr in a shell script
February 14th, 2008 by Lawrence David
to send the standard output and standard error streams from your shell script somewhere, place the following at the top of your script:
#!/bin/bash
exec &> output.file;
[the rest of your code]