Skip to content

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:
echo "a test" | tee >(logger)

  • Twitter
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg bash: how to send output to the console and through a pipe at the same time with tee
  • Mixx bash: how to send output to the console and through a pipe at the same time with tee
  • Bloglines bash: how to send output to the console and through a pipe at the same time with tee
  • Technorati bash: how to send output to the console and through a pipe at the same time with tee
  • Fark this: bash: how to send output to the console and through a pipe at the same time with tee
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at YahooMyWeb
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at Furl.net
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at reddit.com
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at blinklist.com
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at Spurl.net
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at NewsVine
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at Simpy.com
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee at blogmarks
  • Bookmark bash: how to send output to the console and through a pipe at the same time with tee with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Print this article!
  • E-mail this story to a friend!
  • Identi.ca