News for hackers. Stuff that matters.
Re:Unix Commands I Abuse Every Day by njs12345 on Wednesday September 05, 2012 @09:26PM (#4482415)
So the two are different because awk's call to read() is effectively the same as a read directly from a file, whereas copying is taking place through the pipe with the pipeline approach?
Re:Unix Commands I Abuse Every Day by jlgreco on Wednesday September 05, 2012 @10:10PM (#4482520)
Basically you see a linear increase in time. If it was going to take a coffee break's worth of time one way, it will take a slightly longer coffee break worth of time the other. It is fairly rare that the additional time involved matters and there isn't something else that you should be doing anyway.
Re:Unix Commands I Abuse Every Day by ralph on Thursday September 06, 2012 @05:29AM (#4483450)
The difference between

    cat file | foo
    foo <file
assuming foo only reads stdin so `foo file' isn't possible, is that with the latter the shell will open file for reading on file descriptor 0 (stdin) before execing foo and the only cost is the read(2)s that foo does directly from file.

With the needless cat we have cat having to read the bytes and then write(2) them whereupon foo reads them as before. So the number of system calls goes from R to R+W+R assuming all reads and writes use the same block size and more byte copying may be required.