Possible Duplicate:
Should I care about unnecessary cats?

Both would be functionally equivalent, but when using cat wouldn't it be slower because you have a process first reading the file and then sending it through a pipe to another process, instead of the process just reading the file? But I've seen this usage 'cat file | program' in a lot of examples. I assume they wouldn't use it that much in examples if it had bad performance.

marked as duplicate by Caleb, Gilles, Michael Mrozek Jul 17 '11 at 19:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Yes, but the bigger slowdown would be starting up the first process(cat).

However, seeing as how the difference is minimal on any computer made in the last 15 years that isn't loaded down very heavily(load avg < 30), the bigger disadvantage is code readability.

  • A big +1 for the practical advice, focusing on readability. – Cascabel Jul 17 '11 at 7:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.