문제

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