Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Filtering an array of file names



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