How to redirect console output to file and STILL get it in the console? How to redirect console output to file and STILL get it in the console? unix unix

How to redirect console output to file and STILL get it in the console?


Use tee.

ant 2>&1|tee build.log

tee.exe is also available for Windows from http://unxutils.sourceforge.net/


You can use tee.

Example:

$ echo "Hello, world" | tee /tmp/outfileHello, world$ cat /tmp/outfileHello, world

tee writes its stdin to both stdout as well as one or more files given on the command line.