Bernhard Voelker <[email protected]> writes: >> As I wrote in the info page, "the -s option is more efficient than piping >> large amounts of output of find into the sort command, [...] > > Why exactly is that more efficient? Which resources are saved by that? > CPU, RAM (*), time, ...?
"find -s" requires find to store, at any one time, the sorted entries of all of the directories on the path above the current directory. But "find | sort" requires the entire output of find to be stored until find completes. In a sort-of-typical-asymptotic way the second is exponentially larger than the first. If you made a tree of directories containing two entries, 20 layers deep, there would be a million entries to be sorted, but find -s would only need to keep track of 40 at any one time. Dale
