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.

1
  • 1
    man tee Commented Oct 1, 2014 at 10:18

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.