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 % 

 

 

 

 

 

 

 

posted @ 2020-11-03 15:49  anobscureretreat  阅读(126)  评论(0编辑  收藏  举报