sh 脚本练习

code

#!/bin/bash
# storing STDOUT, then coming back to it
exec 3>&1
exec 1>test14out
echo "This should store in the output file"
echo "along with this line."
echo "and this should be stored in the file" >&3
exec 1>&3
echo "Now things should be back to normal"
echo "xxxxxxxxxxx" >&3

输出

macname@MacdeMBP sh % ./test.sh 
and this should be stored in the file
Now things should be back to normal
xxxxxxxxxxx
macname@MacdeMBP sh % 

原文地址:https://www.cnblogs.com/sea-stream/p/13920683.html