help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Is there a way to swap stdout with stderr?


From: Bob Proulx
Subject: Re: [Help-bash] Is there a way to swap stdout with stderr?
Date: Mon, 25 Jul 2016 12:42:28 -0600
User-agent: Mutt/1.5.24 (2015-08-30)

Eduardo A. Bustamante López wrote:
> Peng Yu wrote:
> > Hi, I want to swap stdout and stderr of a command. I.e., I want to
> > print the output of stdout to stderr and the output of stderr to
> > stdout. Is there is a way to do so?
> 
> I'd do something like:
> 
> |    command 3>&1 1>&2 2>&3
> 
> The fd #3 works as a temporary variable to help in the swap.

And then 3>&- to close the temporary 3 to complete the cleanup. :-)

  command 3>&1 1>&2 2>&3 3>&-

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]