bash: how to send output to the console and through a pipe at the same time with tee
Let's say you want some output to be echoed to the console but also to be passed to a pipe. Specifically, in my case I wanted a message to be displayed to the user and also to be sent to syslog. You could of course just print it twice, but in some cases it's not possible, or it makes it more complicated than it should be.
There is a simple solution with tee:
There is a simple solution with tee:
echo "a test" | tee >(logger)
Comments
Display comments as Linear | Threaded