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

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options