On Sun, Aug 2, 2015 at 6:35 AM, Alessandro DE LAURENZIS
<[email protected]> wrote:
> On Sun 02/08/2015 08:23, Alessandro DE LAURENZIS wrote:
>> operation); this could probably be more appropriate:
>>
>> alias nof='find ./ -type f -maxdepth 1 | wc -l'
>
> Ok, that's clearly inefficient because the search is performed in all
> subtrees, instead of cwd only; maybe this:
>
> find . ! -name . -prune -type f -print | wc -l

This approach also counts hidden files while the original did not
include those in the count.

That said, to avoid the inefficiency of searching the subtrees, all
you had to do was reverse -type and -maxdepth:

find . -maxdepth 1 -type f | wc -l

And this should be more efficient than descending into each subtree
and then pruning it as your first action.

Thanks,

-- 
Raul

Reply via email to