findutils-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add sort option to find


From: Dale R. Worley
Subject: Re: Add sort option to find
Date: Wed, 02 Sep 2020 22:22:30 -0400

Bernhard Voelker <mail@bernhard-voelker.de> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]