How can i use tee to send all output to stdout and grepped output to file?
You could try:
./process.sh | { tee /dev/tty | grep foo > output.log; }
this doesn't send output to stdout, but to the tty. Perhaps that is good enough.
or you could do:
./process.sh | awk '/foo/{ print > "output.log"} 1'
which prints all the output of process.sh
to stdout, and lines that match foo
are written to the file.
Also, you can do:
mkfifo fifo./process.sh | { cat fifo & tee fifo | grep foo > output.log; }rm fifo
That can be done more cleanly with a /proc
filesystem:
./process.sh | { tee /proc/self/fd/6 | grep foo > output.lot; } 6>&1