in reply to Re^2: capturing stderr of a command, invoked via backticks (2>&1)
in thread capturing stderr of a command, invoked via backticks

The "| cat" part is superfluous.
Hmmm, you're right of course. I think I formed the habit from shell-isms like so:
./script 2>&1 > file
In that case, without the |cat STDERR is not redirected to file, but that's probably another of my mis-understandings of the mechanism involved.

-David

Replies are listed 'Best First'.
Re^4: capturing stderr of a command, invoked via backticks (order)
by tye (Sage) on Sep 08, 2007 at 05:02 UTC

    foo 2>&1 >file is useful but does something other than WYM (what you mean). Order matters. 2>&1 changes STDERR to go where STDOUT currently is and "redirectives" are processed from left to right. So foo 2>&1 >file | bar sends foo's STDOUT to file and foo's STDERR to bar's STDIN. What you want is foo >file 2>&1 which sends both STDOUT and STDERR to file (you have to dup STDERR to match STDOUT after you've redirected STDOUT to the file).

    - tye