Quoth Martti Kühne: > On Thu, Jul 18, 2013 at 9:00 PM, Galos, David > <galos...@students.rowan.edu> wrote: > > Based on the discussion in 'coreutils / moreutils - DC a directory counter' > > I have optimized sbase ls to easily handle large directories. The major > > change is that ls no longer calls 'lstat' on files if it does not have to. > > > > This patch also add '-U' which keeps the list from being sorted. When using > > '-U', ls is constant (except for an argv duplicate) memory. > > > While we're at it, why not fully remove the necessity of wc -l?
Because 'wc -l' is a much better way to do things in the general case. Remember, "do one thing and do it well". As has already been discussed to death, it's only very unusually large directories that using regular ls|wc -l isn't a reasonable thing to do. But even if it was always slow, this would be the wrong thing to do.