command 2>&1 >logfile
command >logfile 2>&1
的区别:
Multiple output streams may be redirected to one file.
ls −yz >> command.log 2>&1
# Capture result of illegal options "yz" in file "command.log."
# Because stderr is redirected to the file,
#+ any error messages will also be there.
# Note, however, that the following does *not* give the same result.
ls −yz 2>&1 >> command.log
# Outputs an error message and does not write to file.
# If redirecting both stdout and stderr,
#+ the order of the commands makes a difference
阅读(1370) | 评论(0) | 转发(0) |