bash - If redirecting STDERR to STDOUT and redirecting STDOUT to a file, why are STDERR messages not showing in the file? -
i made quick little script, test.sh, looks following:
echo "stderr" > /dev/stderr echo "stdout" > /dev/stdout
according answers so question, , advanced bash-scripting guide, following should redirect stderr stdout script above:
$ sh /tmp/test.sh 2>&1
and indeed does:
$ sh /tmp/test.sh 2>&1 |tee file; $ cat file stderr stdout
the question wondering output stderr go in following code?
$ sh /tmp/test.sh > file 2>&1 $ cat file stdout
i using gnu bash, version 4.0.24(2)-release.
i'm seeing output stderr going file, expected:
$> sh test.sh > file 2>&1 $> cat file stderr stdout
this bash 3.2.48.
$> bash --version gnu bash, version 3.2.48(1)-release (x86_64-apple-darwin11)
Comments
Post a Comment