Search code examples
bashstderrtee

Bash: tree direction in sub-shell working incorrectly


I tested this on a CentOS machine a while back and it worked nicely. Now on another machine, I try this and it fails to work. What is incorrect?

command 2> >(tee stderr.log >&2) && exit

I get this message back.

sh: syntax error near unexpected token `>'

Any suggestions?


Solution

  • The answer is in the error message. The traditional Bourne shell (sh) doesn't support process substitution (e.g. >(command)). You weren't using Bash. You can change your default shell using the chsh command.