The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 09-28-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,246
I disagree:


Code:
#!/bin/ksh
#
# test.sh : demonstrate redirection
#
#
echo "I am stdout"
echo "I am stderr" >&2


Code:
# ./test.sh > log1
I am stderr
# cat log1
I am stdout


Code:
# ./test.sh 2>&1 > log2
I am stderr
# cat log2
I am stdout


Code:
# ./test.sh > log3 2>&1
# cat log3
I am stdout
I am stderr

The order of redirection is important because if the duplication happens from 2 to 1 before redirection of 1, error output is redirected to fd1 ( stdout ) and standard output is redirected elsewhere. On the other hand if it happens afterwards the duplication is to "the same place as standard output"