Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 499
user219882 Avatar asked Jun 16 '11 12:06

user219882


1 Answers

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

like image 73
James C Avatar answered Sep 20 '22 16:09

James C