在脚本中重定向输出_永久重定向
#!/bin/bash
echo "********** 永久重定向输出 **********"
echo "使用exec命令,它会告诉shell在脚本执行期间重定向某个特定文件描述符"
# redirecting all output to a file
exec 1>testout
echo "this is a test of redirecting all output"
echo "from a script to another file."
echo "without having to redirect every individual line"
运行结果
********** 永久重定向输出 **********
使用exec命令,它会告诉shell在脚本执行期间重定向某个特定文件描述符
cat testout
this is a test of redirecting all output
from a script to another file.
without having to redirect every individual line