Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Filtering an array of file names
- X-seq: zsh-users 21988
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Filtering an array of file names
- Date: Thu, 29 Sep 2016 09:38:29 +0200
- 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; bh=ze5Y9eArTcjS7nUdbxa/K6uOcQh8ETwiUDmgEC1xtt4=; b=zciJbJWiA6yRXN3gJhS7+DrR2MPPA4Zq0RF2tu/tBQxirZelqSVoPZcwBxo8kReQyN nhZMiqxKeN2BzfcokR3xigsH8eb7gomrUC/7WEPeHV3oKpjypFMMB3GGJIwYbQW2Hcci d8ipxCBgfwkPico9oZ8Kwap/f+HyndnUv/PKG6XdAWLG77vFYYv4xa4SWfqjOtbfo5OY 7LvAtbITej3i9+83FIHZz+rR6ehRUopCw+Yt6P8xkfMEyI0UT9A3XoU3hO3hA1vaQQzP Dn3ynqUp4mtLqNAgwNYlOA6is9qGfXcyeJFtkh8V/XY97+z/Pxz8i9sJ7VQQk7jhmh/J wVzA==
- 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>
Thank you, Bart! This works perfectly.
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 didn't work on some old versions of the shell, where qualifiers
> were interpreted only if the preceding word had a globbing character.)
>
> If they don't refer to the local filesystem, you'll need the array to
> have already marked them somehow, such as with a trailing slash, and
> then ${(M)files:#*/} would work.
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author