-1

I have a script that QA Manager runs. I want him to take a look at terminal from time to time to take a note if any errors appear.

The problem is that the script have a ton of output that we do not need to see.

What I am trying to implement:

  • stderr only goes to terminal
  • stdout only goes to full-log.txt
  • stderr goes to full-log.txt as well as stdout

Another way is to

  • stderr with stdout go to full-log.txt
  • stderr only go error-log.txt

Will be very grateful if someone can help with that.

Dzmitry Dranitski
  • 165
  • 1
  • 4
  • 13
  • `cmd 2>&1 | tee full-log.txt` could possibly be ok, if you want `stdout` on the terminal too. – Ted Lyngmo Jul 20 '20 at 11:32
  • See also https://stackoverflow.com/questions/692000/how-do-i-write-stderr-to-a-file-while-using-tee-with-a-pipe – limido Jul 20 '20 at 11:36
  • 2
    Does this answer your question? [Redirect stderr and stdout in Bash](https://stackoverflow.com/questions/637827/redirect-stderr-and-stdout-in-bash) – Digvijay S Jul 20 '20 at 12:05

1 Answers1

1

with bash, using a process substitution, with the redirections performed in this order:

cmd 2> >(tee -a full-log.txt) >full-log.txt

Demo:

$ { echo "this is stdout"; echo "this is stderr" >&2; } 2> >(tee -a full-log.txt) >full-log.txt
this is stderr
$ cat full-log.txt
this is stdout
this is stderr
glenn jackman
  • 238,783
  • 38
  • 220
  • 352