linux-tutorial/codes/shell/输入和输出/创建自己的重定向/从以重定向的文件描述符中恢复.sh

14 lines
209 B
Bash
Raw Normal View History

2019-10-29 18:22:19 +08:00
#!/usr/bin/env bash
2019-05-10 11:17:57 +08:00
#storing STDOUT, then coming back to it
exec 3>&1
2019-10-10 08:56:31 +08:00
exec 1> test
2019-05-10 11:17:57 +08:00
echo "This should store in output file"
echo "along with this line"
exec 1>&3
echo "Now things should be back to normal"