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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top