I made a quick little script, test.sh, that looks like the following:
echo "StdErr" > /dev/stderr
echo "StdOut" > /dev/stdout
According to the answers to this SO question, and the Advanced Bash-Scripting Guide, the following should redirect stderr to stdout from the script above:
$ sh /tmp/test.sh 2>&1
And indeed it does:
$ sh /tmp/test.sh 2>&1 |tee file;
$ cat file
StdErr
StdOut
The question that I am wondering is where does the output from stderr go in the following code?
$ sh /tmp/test.sh > file 2>&1
$ cat file
StdOut
I am using GNU bash, version 4.0.24(2)-release.