Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top