echo "error" 1>&2 | tee -a log
With the first part 1>&2
, what you are saying is: "Redirect stdout to stderr". So the echoed output "error"
goes to stderr.
Pipe (|
) only reads from stdout
, not stderr
. So tee
doesn't get any stdin
at all from the pipe. Hence, it appends nothing to the log file.