Ive got approximately the following code:cat infile | while read line; do    echo 2> 'log ' $line    echo $linedone > outfileoutfile is created correctly. However, the STDERR output just vanished: its 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)?
Write to error stream in while loop
bash;io redirection
Your syntax is wrong: it should be >&2 not 2>.