使用 bash,如何将 stderr 和 stdout 复制到日志文件并将它们显示在控制台上?
我想使用 exec 在脚本本身中执行此操作。
我试过
exec &>> log.out echo "This is stdout" echo "This is stderr" >&2
但是上面的内容在控制台上没有打印任何内容。我怎样才能在 bash 中实现这一点?
bash stderr exec
bash ×1
exec ×1
stderr ×1