我可以使用以下命令将stdout和stderr重定向到单独的文件:
dir >> out 2>> error
使用以下命令将stderror和stdout合并为一个文件:
dir >> consolidate 2>&1
解决方法:
您可以尝试以下方式:
(command > >(tee out.txt) 2> >(tee error.txt >&2)) &> consol.txt
测试:
$ls
f
$ls g*
ls: cannot access g*: No such file or directory
$(ls g f > >(tee out.txt) 2> >(tee error.txt >&2)) &> consol.txt
$cat out.txt
f
$cat error.txt
ls: cannot access g: No such file or directory
$cat consol.txt
f
ls: cannot access g: No such file or directory