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.
Output redirection inside/outside square brackets in Bash
-
31-03-2022 - |
Вопрос
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?
Решение
Не связан с StackOverflow