Redirecting standard output (stdout) to standard error (stderr)

Some might find this trivial, but it was not trivial to me. If you want to print something to stderr in a shell script, you can redirect the output of a command (eg. echo) to this stream (file handle or whatever):
echo "text" >&2

I've used the stderr->stdout redirection for ages (I mean: command 2>&1), but somehow I did not make the jump from this syntax to the one I was looking for right now.

Thanks to airwin for helping me out with this. Smiling

Syndicate content