shell
输出重定向 &>
与 2>&1
man page
Redirecting Standard Output and Standard Error
This construct allows both the standard output (file descriptor 1) and
the standard error output (file descriptor 2) to be redirected to the
file whose name is the expansion of word.
There are two formats for redirecting standard output and standard
error:
&>word
and
>&word
Of the two forms, the first is preferred. This is semantically equiva‐
lent to
>word 2>&1
>
Syntax:file_descriptoropt > file_name
>&
Syntax:file_descriptoropt >& file_descriptor
&>
Syntax:&> file_name
If the file descriptor is omitted, the default is 0 (stdin) for input, or 1 (stdout) for output. 2 means stderr.
>name
means1>name
– redirect stdout to the file name&>name
means1>name 2>name
– redirect stdout and stderr to the file name
Example
udhcpc -t 20 -T 1 -n -q -i "$dev" &> "logs"