Reputation: 15834
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
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
Reputation: 15353
See this post. You will need to use the tee command to direct in multiple directions.
Upvotes: 0