jython.li jython.li - 10 months ago 39
Bash Question

When use "exec 1>ok.log", how can I output the specified content to the screen within a shell script?

As follow, I only want the command

echo "this is to stdout"
output to my screen instead of to the file
, how can I do?

I search for the usage of
shell command, but without result, please advice me

[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
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


You can write directly to the terminal of the controlling process with

echo "this is to stdout" > /dev/tty