What is the difference (if any) between “cat input | tee > output” and “tee output”?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
-2
down vote

favorite












I obtained the following:



$ time $(tee < infile > outfile)
real 0m14.721s
user 0m0.094s
sys 0m2.629s

$ time $(cat infile | tee > outfile)
real 0m8.931s
user 0m0.123s
sys 0m3.168


Is that difference just owing to redirection/piping, or is there something else going on here? Running them a second time gave the following:



$ time $(tee < infile > outfile)
real 0m11.558
user 0m0.113s
sys 0m2.691s

$ time $(cat infile | tee > outfile)
real 0m8.822s
user 0m0.120s
sys 0m3.125s


PS: Both infile and outfile were mp4 files, cached in ram; if that makes any difference.



Edit: I meant tee < infile > outfile and not tee < infile tee > outfile.







share|improve this question





















  • Note: no need for $() it will result in output being thrown away, and time does not need it. () would be good though.
    – ctrl-alt-delor
    Jul 28 at 10:17











  • You just edited the commands, but leave the timings for the old commands. ☹ (-1)
    – ctrl-alt-delor
    Jul 28 at 10:46











  • .. because that was the result I obtained ... I had made the mistake in the body.
    – Shubham1999
    Jul 28 at 11:00










  • I did not believe you so, I have just repeated the experiment. The one with cat is slower. I still don't believe you.
    – ctrl-alt-delor
    Jul 28 at 11:20











  • Why do you time the result of executing the output of those commands?
    – Kusalananda
    Jul 28 at 11:44
















up vote
-2
down vote

favorite












I obtained the following:



$ time $(tee < infile > outfile)
real 0m14.721s
user 0m0.094s
sys 0m2.629s

$ time $(cat infile | tee > outfile)
real 0m8.931s
user 0m0.123s
sys 0m3.168


Is that difference just owing to redirection/piping, or is there something else going on here? Running them a second time gave the following:



$ time $(tee < infile > outfile)
real 0m11.558
user 0m0.113s
sys 0m2.691s

$ time $(cat infile | tee > outfile)
real 0m8.822s
user 0m0.120s
sys 0m3.125s


PS: Both infile and outfile were mp4 files, cached in ram; if that makes any difference.



Edit: I meant tee < infile > outfile and not tee < infile tee > outfile.







share|improve this question





















  • Note: no need for $() it will result in output being thrown away, and time does not need it. () would be good though.
    – ctrl-alt-delor
    Jul 28 at 10:17











  • You just edited the commands, but leave the timings for the old commands. ☹ (-1)
    – ctrl-alt-delor
    Jul 28 at 10:46











  • .. because that was the result I obtained ... I had made the mistake in the body.
    – Shubham1999
    Jul 28 at 11:00










  • I did not believe you so, I have just repeated the experiment. The one with cat is slower. I still don't believe you.
    – ctrl-alt-delor
    Jul 28 at 11:20











  • Why do you time the result of executing the output of those commands?
    – Kusalananda
    Jul 28 at 11:44












up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I obtained the following:



$ time $(tee < infile > outfile)
real 0m14.721s
user 0m0.094s
sys 0m2.629s

$ time $(cat infile | tee > outfile)
real 0m8.931s
user 0m0.123s
sys 0m3.168


Is that difference just owing to redirection/piping, or is there something else going on here? Running them a second time gave the following:



$ time $(tee < infile > outfile)
real 0m11.558
user 0m0.113s
sys 0m2.691s

$ time $(cat infile | tee > outfile)
real 0m8.822s
user 0m0.120s
sys 0m3.125s


PS: Both infile and outfile were mp4 files, cached in ram; if that makes any difference.



Edit: I meant tee < infile > outfile and not tee < infile tee > outfile.







share|improve this question













I obtained the following:



$ time $(tee < infile > outfile)
real 0m14.721s
user 0m0.094s
sys 0m2.629s

$ time $(cat infile | tee > outfile)
real 0m8.931s
user 0m0.123s
sys 0m3.168


Is that difference just owing to redirection/piping, or is there something else going on here? Running them a second time gave the following:



$ time $(tee < infile > outfile)
real 0m11.558
user 0m0.113s
sys 0m2.691s

$ time $(cat infile | tee > outfile)
real 0m8.822s
user 0m0.120s
sys 0m3.125s


PS: Both infile and outfile were mp4 files, cached in ram; if that makes any difference.



Edit: I meant tee < infile > outfile and not tee < infile tee > outfile.









share|improve this question












share|improve this question




share|improve this question








edited Jul 28 at 10:24
























asked Jul 28 at 9:45









Shubham1999

12




12











  • Note: no need for $() it will result in output being thrown away, and time does not need it. () would be good though.
    – ctrl-alt-delor
    Jul 28 at 10:17











  • You just edited the commands, but leave the timings for the old commands. ☹ (-1)
    – ctrl-alt-delor
    Jul 28 at 10:46











  • .. because that was the result I obtained ... I had made the mistake in the body.
    – Shubham1999
    Jul 28 at 11:00










  • I did not believe you so, I have just repeated the experiment. The one with cat is slower. I still don't believe you.
    – ctrl-alt-delor
    Jul 28 at 11:20











  • Why do you time the result of executing the output of those commands?
    – Kusalananda
    Jul 28 at 11:44
















  • Note: no need for $() it will result in output being thrown away, and time does not need it. () would be good though.
    – ctrl-alt-delor
    Jul 28 at 10:17











  • You just edited the commands, but leave the timings for the old commands. ☹ (-1)
    – ctrl-alt-delor
    Jul 28 at 10:46











  • .. because that was the result I obtained ... I had made the mistake in the body.
    – Shubham1999
    Jul 28 at 11:00










  • I did not believe you so, I have just repeated the experiment. The one with cat is slower. I still don't believe you.
    – ctrl-alt-delor
    Jul 28 at 11:20











  • Why do you time the result of executing the output of those commands?
    – Kusalananda
    Jul 28 at 11:44















Note: no need for $() it will result in output being thrown away, and time does not need it. () would be good though.
– ctrl-alt-delor
Jul 28 at 10:17





Note: no need for $() it will result in output being thrown away, and time does not need it. () would be good though.
– ctrl-alt-delor
Jul 28 at 10:17













You just edited the commands, but leave the timings for the old commands. ☹ (-1)
– ctrl-alt-delor
Jul 28 at 10:46





You just edited the commands, but leave the timings for the old commands. ☹ (-1)
– ctrl-alt-delor
Jul 28 at 10:46













.. because that was the result I obtained ... I had made the mistake in the body.
– Shubham1999
Jul 28 at 11:00




.. because that was the result I obtained ... I had made the mistake in the body.
– Shubham1999
Jul 28 at 11:00












I did not believe you so, I have just repeated the experiment. The one with cat is slower. I still don't believe you.
– ctrl-alt-delor
Jul 28 at 11:20





I did not believe you so, I have just repeated the experiment. The one with cat is slower. I still don't believe you.
– ctrl-alt-delor
Jul 28 at 11:20













Why do you time the result of executing the output of those commands?
– Kusalananda
Jul 28 at 11:44




Why do you time the result of executing the output of those commands?
– Kusalananda
Jul 28 at 11:44










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










The examples are not the same as in the title.



For the question in the title.



The version with cat will be marginally slower.



For the question in the body



The first command, is writing two files. This is why is is slower.
The second is starting an extra process (cat), but this is a small slowdown compared to writing extra file.



The second run is faster, probably, because the read is cached.



Explenation



tee < infile tee > outfile is functionally equivalent, but faster than cat infile | tee tee > outfile, where as tee > outfile is not. The first two produce two file, the 3rd produces one, so will be faster.






share|improve this answer























  • Look again tee > outfile it only has one output.
    – ctrl-alt-delor
    Jul 28 at 10:16










  • Thanks for pointing out! Sorry, I had written it wrongly; but I checked my history - the title is what I meant.
    – Shubham1999
    Jul 28 at 10:26










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459023%2fwhat-is-the-difference-if-any-between-cat-input-tee-output-and-tee-in%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










The examples are not the same as in the title.



For the question in the title.



The version with cat will be marginally slower.



For the question in the body



The first command, is writing two files. This is why is is slower.
The second is starting an extra process (cat), but this is a small slowdown compared to writing extra file.



The second run is faster, probably, because the read is cached.



Explenation



tee < infile tee > outfile is functionally equivalent, but faster than cat infile | tee tee > outfile, where as tee > outfile is not. The first two produce two file, the 3rd produces one, so will be faster.






share|improve this answer























  • Look again tee > outfile it only has one output.
    – ctrl-alt-delor
    Jul 28 at 10:16










  • Thanks for pointing out! Sorry, I had written it wrongly; but I checked my history - the title is what I meant.
    – Shubham1999
    Jul 28 at 10:26














up vote
1
down vote



accepted










The examples are not the same as in the title.



For the question in the title.



The version with cat will be marginally slower.



For the question in the body



The first command, is writing two files. This is why is is slower.
The second is starting an extra process (cat), but this is a small slowdown compared to writing extra file.



The second run is faster, probably, because the read is cached.



Explenation



tee < infile tee > outfile is functionally equivalent, but faster than cat infile | tee tee > outfile, where as tee > outfile is not. The first two produce two file, the 3rd produces one, so will be faster.






share|improve this answer























  • Look again tee > outfile it only has one output.
    – ctrl-alt-delor
    Jul 28 at 10:16










  • Thanks for pointing out! Sorry, I had written it wrongly; but I checked my history - the title is what I meant.
    – Shubham1999
    Jul 28 at 10:26












up vote
1
down vote



accepted







up vote
1
down vote



accepted






The examples are not the same as in the title.



For the question in the title.



The version with cat will be marginally slower.



For the question in the body



The first command, is writing two files. This is why is is slower.
The second is starting an extra process (cat), but this is a small slowdown compared to writing extra file.



The second run is faster, probably, because the read is cached.



Explenation



tee < infile tee > outfile is functionally equivalent, but faster than cat infile | tee tee > outfile, where as tee > outfile is not. The first two produce two file, the 3rd produces one, so will be faster.






share|improve this answer















The examples are not the same as in the title.



For the question in the title.



The version with cat will be marginally slower.



For the question in the body



The first command, is writing two files. This is why is is slower.
The second is starting an extra process (cat), but this is a small slowdown compared to writing extra file.



The second run is faster, probably, because the read is cached.



Explenation



tee < infile tee > outfile is functionally equivalent, but faster than cat infile | tee tee > outfile, where as tee > outfile is not. The first two produce two file, the 3rd produces one, so will be faster.







share|improve this answer















share|improve this answer



share|improve this answer








edited Jul 28 at 10:16


























answered Jul 28 at 10:04









ctrl-alt-delor

8,54031946




8,54031946











  • Look again tee > outfile it only has one output.
    – ctrl-alt-delor
    Jul 28 at 10:16










  • Thanks for pointing out! Sorry, I had written it wrongly; but I checked my history - the title is what I meant.
    – Shubham1999
    Jul 28 at 10:26
















  • Look again tee > outfile it only has one output.
    – ctrl-alt-delor
    Jul 28 at 10:16










  • Thanks for pointing out! Sorry, I had written it wrongly; but I checked my history - the title is what I meant.
    – Shubham1999
    Jul 28 at 10:26















Look again tee > outfile it only has one output.
– ctrl-alt-delor
Jul 28 at 10:16




Look again tee > outfile it only has one output.
– ctrl-alt-delor
Jul 28 at 10:16












Thanks for pointing out! Sorry, I had written it wrongly; but I checked my history - the title is what I meant.
– Shubham1999
Jul 28 at 10:26




Thanks for pointing out! Sorry, I had written it wrongly; but I checked my history - the title is what I meant.
– Shubham1999
Jul 28 at 10:26












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459023%2fwhat-is-the-difference-if-any-between-cat-input-tee-output-and-tee-in%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?