当使用“exec 1> ok.log”时,如何将指定的内容输出到shell脚本中的屏幕上?

如下所示,我只希望命令echo "this is to stdout"输出到我的屏幕,而不是文件ok.log ,我该怎么办?
我searchexec shell命令的用法,但没有结果,请指教我

 [root@161 tmp]# bash --version GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2011 Free Software Foundation, Inc. [root@161 tmp]# cat 2.sh #!/bin/bash exec 1>ok.log exec 2>error.log #exist dir ls /home/ #no exist dir ls /etca/ #to stdout echo "this is to stdout" #other cmds ... 

您可以将原始stdout保存到临时文件描述符,然后redirect它。 在这个例子中,我使用文件描述符3。

 exec 3>&1 exec 1>ok.log echo "This will go to ok.log" echo "This will go to the original stdout" >&3