Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .