On Sat, 11 Mar 2006, Alan Gauld wrote: > But surely the string command will take just as long to run regardless > of whether you use pipes or read the output into Python?
Surely it will! Except that it doesn't. > Are ytou saying that running strings on its own takes 10 minutes but > running it in a pipe takes only a few seconds? Yes, exactly. Not any pipe, though; a pipe that is satisfied and closes down after just the first few hundred lines or so. > What happens if you redirect the strings output to a file instead of a > pipe I haven't tried directing it to an actual file, but when directing it to nul: it's about 10-15 minutes; while directing it to the pipe is just a few seconds. I gotta admit, this took me by surprise, too, but my guess is that once the head command is done, it closes the pipe it's reading from, which is being filled by grep; grep takes the hint and terminates, closing the pipe it's reading from, which is being filled by strings; and strings takes the hint and terminates, even though it hasn't gotten through the entire file. And that all happens in a second or two. _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
