How to redirect "stdout" to screen and "egrep"

I’m running the following command in a script file:

rsync -rtovci /home/gumper/New\ test\ data/ /media/MyBook/New\ test\ data | egrep -c "Backup|Database" > /home/gumper/logfile_newtest

When running the script, the output of the rsync commands are not being displayed on the screen. I guess this is because they are getting piped to egrep. Is there a way that I can both display the output of rsync and send it to egrep as well?

I thought about using the “tee” command but I think that this will only send the stdout of rsync to a file.

Any ideas?

Gumper wrote:

> When running the script, the output of the rsync commands are not being
> displayed on the screen. I guess this is because they are getting piped
> to egrep. Is there a way that I can both display the output of rsync and
> send it to egrep as well?

man tee, and if it is stderr that needs to be piped use 2| instead of |. man bash in that case.


Ruurd

Yes, it goes to a file. Use /dev/tty for the filename and it goes to the terminal again:

rsync .... | tee /dev/tty | grep .........

Thanks, that did the trick!