理解输入和输出_创建输出文件描述符
#!/bin/bash
# 可以用exec命令分配用于输出的文件描述符。
# 一旦将替代性文件描述符指向文件,此重定向就会一直有效,直至重新分配。
# using an alternative file descriptor
exec 3>testout
echo
echo "this should display on the monitor"
echo "and this should be stored in the file" >&3
echo "then this should be back on the monitor"
运行结果
this should display on the monitor
then this should be back on the monitor
cat testout
and this should be stored in the file