It's actually two different operators which conflict with each other, one from the Bourne shell, one from the C shell.
Is the Bourne shell operator that runs
cmd with its stdout (fd 1) connected to the same resource (same open file description) as that on fd 2 (
x<&y which is exactly the same) redirects fd x to the same resource as on fd y).
cmd >& file
Is the C shell (
csh) operator that runs
cmd with both its fd 1 and 2 connected to a new open file description obtained by opening
file in write-only mode. In Bourne shell syntax, the equivalent would be
cmd > file 2>&1
They do conflict. Which one is actually used depends on whether the target is numerical or not.
If you have:
The Bourne shell operator will be used if
$file contains a sequence of decimal digits and the C shell operator will be used otherwise!
That's why it's better to avoid that csh operator and use the Bourne shell syntax (
> file 2>&1) instead.
zsh) also has a
&> operator as an alternative to
>&, but note that it breaks POSIX compliance as
cmd &> file is meant to run
cmd & and then
> file in POSIX
sh. It does however not have the conflict problem mentioned above.