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 % 

 

 

 

 

 

 

 

相关文章:

  • 2021-12-10
  • 2021-09-17
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-10-09
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2021-09-10
  • 2021-06-25
  • 2021-07-02
相关资源
相似解决方案