0

My sysadmin created a bash script and the first command in it is to redirect the output in a log file:

exec > my_app.log

With this, I have the following:

  • stdout redirected to my_app.log
  • see stderr live in my terminal

When I manually execute the script, I want all of the following:

  • stdout redirected to my_app.log
  • stderr redirected to my_app.err
  • see stdout live in my terminal
  • see stderr live in my terminal

What do I need to change to the exec to have all that to happen?

Currently what I do is open 3 terminals.

  • one to run the script with ./my_script.sh 2> my_app.err
  • one to use tail -f my_app.log
  • one to use tail -f my_app.err

This is too much I think.

Olivier Grégoire
  • 33,839
  • 23
  • 96
  • 137

1 Answers1

1

echo "hello" | tee file.txt

output from echo "hello" put to the file and stdout

if you need stderr and stdout, then echo "hello" 2>&1 | tee file.txt

Ivan Ivanovich
  • 880
  • 1
  • 6
  • 15