Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Fastest way to count # of files?
- X-seq: zsh-users 21854
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Fastest way to count # of files?
- Date: Thu, 8 Sep 2016 18:37:36 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MWHXwL5B/9gRmN1+CmBacH3BD+GGbqYPOmUMVHikqP8=; b=VqFuyGBnLfZG5FbX26mz0MT63mBKw7GX0tYCPkS9TIXU9bLHYbSTIb/YeYKTq8dBv4 9V5PiOtZxe5d1yZFXjfQz7wEPN27RO2z91yWzd9VUmAb2wuj8wypGJ5K+levOJN6UAwa mmd9gz54IDVaG1S9p/YpbObuUHq3que02W61i+2d/3+1FmIofHLnFAEvZoyrJjShrm0E cC7LCemdhDw46TM/DUs3zdKuoPeLDzaXkl15wme+u6hWXXtW/mbdpayTs8q+JSVpYE5i mFmDUs/3wq1X+ILC3YELYhzyGF3OtVtlEMBdr/PXEV3hztfdMnoRiN1lvYq71edIXPea 4uLw==
- In-reply-to: <160908090800.ZM13466@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVApZGBAoQ4GywTLzbJXmNOrq2-W_iP7p+ifWqzYF49N+g@mail.gmail.com> <160908090800.ZM13466@torch.brasslantern.com>
First ran was slower than this and following ones:
% typeset -F SECONDS; myst=$SECONDS; integer nfiles=0; :
**/*(Ne?'((++nfiles)) && reply=()'?); print $nfiles; echo $(( (SECONDS
- myst) * 1000 ))
80001
1427.3609999982
I.e. 1.4 second
Best regards,
Sebastian Gniazdowski
On 8 September 2016 at 18:08, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sep 8, 5:36pm, Sebastian Gniazdowski wrote:
> }
> } [...] The second code reads the whole directory too, but
> } it's slow. First code doesn't provide way to determine # of files
> } read. Is there anything between these two? Something that doesn't
> } store files, but counts them?
>
> Try this:
>
> integer nfiles=0
> : **/*(Ne?'((++nfiles)) && reply=()'?)
> print $nfiles
Messages sorted by:
Reverse Date,
Date,
Thread,
Author