Re: multiple inputs / outputs through descriptors

[email protected] (Bob Proulx) Sun, 31 Aug 2003 17:21:06 -0600
Newsgroups gmane.comp.gnu.textutils.bugs
Message-ID <[email protected]>
[email protected] wrote:
> aside: Do you know whether there is a way to *switch* two
> descriptors (like stdout / stderr) ? I.e. the intuitive
> '( ls -d / /asdfasdf 1>&2 2>&1 ) >err 2>out' doesn't work.

As with the classic variable swap trivia problem in a program you need
a temporary variable to hold the value so that you can swap everything
round robin fashion.  The last part closes the temporary and cleans up.

  ( ls -d / /asdfasdf 3>&2 2>&1 1>&3 3>&- ) >err 2>out

Bob