Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Filtering an array of file names
- X-seq: zsh-users 21991
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Filtering an array of file names
- Date: Thu, 29 Sep 2016 09:54:13 +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=GANnL4io9dai6cf30hS3H9tYad6tuvQFEEi57gPT9a0=; b=G3W70FpYUsfpkAhyYAt7mPVs+jPR0hrcqD8t5VepI/1YLzAEFByYe13rL5LNOmtsCp 4vycZ/oI6eyf4Pzi1ughvbAWIww6x8zp5nZwfyEWwOiowQsdc7l7W4Cq79wNTdKt1175 xv/wr53hiJIKP6lzcmrzIqtnzATKAAEQ6w/+p5kqknn0BoVpq//32utuUEfIJ+1iF8Ej h0G7l5uqsu0WJkVHc8LmJkKqGtuiGFH+vW6AL4tK9gAhbn9/BVtwknywg5MH6pJEnaw/ 8o7WHyAffsJF2IvQYNC0qY9b0AeYZit9pol3zD++ttGmjPVRt03y21jUu+FowL3H668g a7Qg==
- In-reply-to: <160929001853.ZM27784@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: <CABZhJg9vf0OZyXbSOcX_7sA7aN=cHtDQq08sLKy_0Vs6xkUR1g@mail.gmail.com> <160929001853.ZM27784@torch.brasslantern.com>
On Thu, Sep 29, 2016 at 9:18 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sep 29, 8:43am, Jesper Nygards wrote:
> }
> } Suppose I have an array of file names, generated from some external
> } program. Is there an zsh-idiomatic way of filtering this array to only
> } keep directories?
>
> Are these local file names that you can compare to the filesystem? If
> so, you can use rc-expand-param and globbing qualifiers:
>
> directories=( ${^allfiles}(/) )
This should be
directories=( ${^allfiles}(/N) )
unless you have nullglob set, otherwise it will either fail or fill up
the directories array with entries like "foo(/)" depending on if
nomatch is set.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author