I want to redirect everything that is supposed to go to stdout
to stderr
, and everything that is going to stderr
to go to stdout
instead.
The following code does not work:
$ bin/stdout-test 1>&2 2>&1
I'm sure there is a practical use for this somewhere out there, but currently it's just a mental exercise to help learn and understand io redirection.
In Ubuntu, both stdout
and stderr
get redirected to the console anyway, so you can't really tell if you are making any progress, but the command tcpserver
will redirect stdout
to the connecting remote user, and stderr
to the terminal that started the tcpserver
session, making it a perfect place to test this type of redirection.
I created a test project just for this purpose: