Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to determine if sed is faster reading from stdin (with shell redirection < ) or by specifying the file from which sed should read. I didn't find a definitive answer on Google.

Which is faster?

sed -e "expression" < file

or

sed -e "expression"   file
share|improve this question
    
why dont you try it out? –  Karthik T Oct 23 '12 at 2:01

1 Answer 1

It should be basically indistinguishable. In both cases, the file has to be opened and a file handle created. In both cases, sed then reads from the file handle. In the first case, the shell opens a file handle and then passes it via process inheritance to sed as a child. In the second case, sed opens the handle directly. As I said, that should be pretty much indistinguishable.

share|improve this answer
    
@AlanShutko: There's no pipe involved here. If you think sed would be reading from a pipe in this case, what do you think is writing to that pipe? –  David Schwartz Oct 23 '12 at 5:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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