user219882
user219882

Reputation: 15834

Bash - output redirection

I'm trying to redirect error output to both a file and the terminal and throw away standard output, but I can't figure it out. Does anybody know how to do it?

Upvotes: 5

Views: 2581

Answers (2)

James C
James C

Reputation: 14149

myCommand 2>&1  1>/dev/null | tee /path/to/some/file.txt

STDOUT gets black-holed into /dev/null

STDERR gets redirected to STDOUT

tee receives STDOUT and re-echoes it as well as writing it to file

Upvotes: 14

nsfyn55
nsfyn55

Reputation: 15353

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

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

Upvotes: 0

Related Questions