Bash 当使用“时”;执行官1>;好的,记录;,如何在shell脚本中将指定的内容输出到屏幕?
如下所示,我只希望命令Bash 当使用“时”;执行官1>;好的,记录;,如何在shell脚本中将指定的内容输出到屏幕?,bash,shell,exec,stdout,Bash,Shell,Exec,Stdout,如下所示,我只希望命令echo“this is to stdout”输出到我的屏幕,而不是文件ok.log,我该怎么办? 我搜索了execshell命令的用法,但没有结果,请告诉我 [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]#
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