>& semi-equivalence (clobber)
zsh manual Redirections section says that:
Both will clobber the file - truncate it file to 0 bytes before writing to it, just like
> file would do in the STDIN-only case.
bash manual Redirections section adds that:
Of the two forms, the first is preferred. This is semantically equivalent to
When using the second form, word may not expand to a number or
-. If it does, other redirection operators apply (see Duplicating File Descriptors below) for compatibility reasons.
So, whilst you tagged
zsh, it's probably good practice to get finger memory in the first form should one ever write a
>> logfile 2>&1 and
&>> equivalence (append)
logfile is not overwritten, but opened for writing at the end of the file, ie append mode (
The equivalent in both
command1 &>> logfile
The format for appending standard output and standard error is:
This is semantically equivalent to
(see Duplicating File Descriptors below).
(Note: the clobber usage of
>& in the section above is again recommended given there is only one way for appending in
zsh allows both