如何组合这两个命令?:./script.sh > logfile.log 和 ./script.sh 2> logfile.log

How to combine these two commands?: ./script.sh > logfile.log and ./script.sh 2> logfile.log

如何组合这两个命令?

./script.sh > logfile.log 

./script.sh 2> logfile.log

谢谢!

在bash中,要将标准输出和标准错误都重定向到同一个文件,可以这样写

./script.sh &> logfile.log

如果想兼容其他shell,

./script.sh > logfile.log 2>&1