I’ve got approximately the following code:
cat infile | while read line; do
echo 2> 'log ' $line
echo $line
done > outfile
outfile
is created correctly. However, the STDERR output just vanished: it’s neither displayed on the terminal nor in outfile
. If I replace the last line above with done > outfile 2> errfile
then errfile
is created, but empty.
Can I capture the error output from within the loop, preferably by streaming it directly into the parent STDERR (the above is part of a larger script whose standard error stream is captured by yet another process)?