Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 当使用“时”;执行官1>;好的,记录;,如何在shell脚本中将指定的内容输出到屏幕?_Bash_Shell_Exec_Stdout - Fatal编程技术网

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