【发布时间】:2014-04-09 07:52:09
【问题描述】:
我们可以使用 EXEC 命令将所有的 STDOUT 和 STDERR 重定向到一个 .log 文件,例如:
#!/bin/bash
exec 1> record.log 2>&1
echo begin redirecting
# from the script above, 'begin redirecting' will be redirected to record.log
# then we want to disable the redirecting and restore the STDOUT&STDERR
echo return to STDOUT and STDERR
# here 'return to STDOUT and STDERR' will be print out
有谁知道如何禁用重定向(STDOUT 和 STDERR)? 这样,我们可以使用 exec 命令将部分输出重定向到文件。 非常感谢。
【问题讨论】:
标签: linux bash shell redirect exec