Bash - output redirection

I am trying to redirect the error output to a file and terminal and throw away the standard output, but I cannot figure it out. Does anyone know how to do this?

+5
source share
2 answers
myCommand 2>&1  1>/dev/null | tee /path/to/some/file.txt

STDOUT goes black in / dev / null

STDERR redirects to STDOUT

tee receives STDOUT and repeats its echo, and also writes it to a file

+14
source

See this post. You will need to use the tee command to direct in several directions.

http://www.linuxforums.org/forum/programming-scripting/163161-redirecting-stdout-file-terminal-stderr-file.html

0
source

All Articles