LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-17-2012, 10:09 AM   #1
laki47
Member
 
Registered: Feb 2009
Posts: 33

Rep: Reputation: 15
tee command - multiple pipes


Hi,

Could you please explain the following (korn shell):

root@server1:/tmp# ls -l file1
-rw-r--r-- 1 root system 4 Feb 17 15:47 file1
root@server1:/tmp# cat file1
123
root@server1:/tmp# cat file1 |tee file2 |tee file3
123
root@server1:/tmp#


Why do I see only one output on stdout no matter there are two "tee" commands? Files "file2" and "file3" are created.

THX!

Last edited by laki47; 02-17-2012 at 10:10 AM.
 
Old 02-17-2012, 10:31 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 210Reputation: 210Reputation: 210
tee simply receives stdout from the pipe chain and reliably reproduces it.

So the output each time goes to the next piped command. The final "tee file3" is the thing that actually ends up dumping to console, because it's the only command whose output is not being piped.

If you want to maintain your tee behaviour, but also see the output as many times as it is copied, you could:

Code:
for i in `seq 1 3`; do
    cat file1 | tee file$i
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tee command in sudoer file pandunr Linux - Software 1 07-26-2011 10:35 AM
how to use tee linux command rami_hachem Linux - Newbie 4 02-08-2011 10:59 AM
tee command implementation hellorajni Linux - Software 2 11-10-2010 01:54 PM
how does tee command implemented? hellorajni Linux - Newbie 1 11-04-2010 03:51 PM
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 02:31 PM


All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration