使用"exec 1>ok.log"时,如何在shell脚本中输出指定内容到屏幕?
When use "exec 1>ok.log", how can I output the specified content to the screen within a shell script?
如下,我只想将命令echo "this is to stdout"
输出到我的屏幕而不是文件ok.log
,我该怎么办?
我搜索了exec
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
...
您可以直接写入控制进程的终端
echo "this is to stdout" > /dev/tty
如下,我只想将命令echo "this is to stdout"
输出到我的屏幕而不是文件ok.log
,我该怎么办?
我搜索了exec
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
...
您可以直接写入控制进程的终端
echo "this is to stdout" > /dev/tty