Output redirection inside/outside square brackets in Bash

Can somebody kindly clarify me if there is any difference concerning redirection between:

[ $var1 -eq $var2 ] &> out.tmp

and

[ $var1 -eq $var2 &> out.tmp ] 

This is, redirecting outside vs. inside square brackets. I googled for an answer with no luck. In Bash, both seem to work the same.

Thank you!

PS: using double square brackets would make a difference?


The bash manual says "... redirection operators may precede or appear anywhere within a simple command or may follow a command." [ ... ] is a simple command (you can look up the definition in the bash manual), so the redirection may appear anywhere. [[ ... ]] is listed as a compound command, so redirection may only follow it.

链接地址: http://www.djcxy.com/p/97072.html

上一篇: 当使用双方括号和单方括号时

下一篇: 在Bash中的方括号内/外输出重定向