From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22887 invoked by alias); 29 Sep 2016 07:38:38 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21988 Received: (qmail 19433 invoked from network); 29 Sep 2016 07:38:38 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f54.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.54):SA:0(0.0/5.0):. Processed in 0.34099 secs); 29 Sep 2016 07:38:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE, SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: jesper.nygards@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.215.54 as permitted sender) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ze5Y9eArTcjS7nUdbxa/K6uOcQh8ETwiUDmgEC1xtt4=; b=WDtzj/Mf7OoKzzrdh27X8wHrhK7vaw9GlaMyA0JX5LvSG+m2FNWAIRkaDAxq0nc5Xc RyMcp3z+UvlaosxO7ukdW0uEBW7fqe5IxCIguQ3bLo0sjkG+0cH9uFRAJsKUkax0YPX9 n3Auh9F1e2CeAfh19PLPP+3f4hfoxpauedLW22mEdrFmOCe8m1qjn6vCmrU/L5BsEmcL D6/5DDGbDrNYcIr2R7pBsezEdWqwV1iEYjhL//y+grVFYCuEt4Z4Es7UizvhRiCtoSve G75JKkdQOOKiyxp6VJFTqDGGTDkE5kG8PihW/b6vXNbbuXiSEwwfVcLSm5krU8RpOXsK aNxQ== X-Gm-Message-State: AA6/9RnYCXmcKZawCA/ry3h45HOo3WySnS94fBRjPo8/fFghN2AAgXrvhaoyAkwSJXB0E4wDHH6l23WBSGjyww== X-Received: by 10.25.167.209 with SMTP id q200mr30052lfe.122.1475134710294; Thu, 29 Sep 2016 00:38:30 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <160929001853.ZM27784@torch.brasslantern.com> References: <160929001853.ZM27784@torch.brasslantern.com> From: =?UTF-8?Q?Jesper_Nyg=C3=A5rds?= Date: Thu, 29 Sep 2016 09:38:29 +0200 Message-ID: Subject: Re: Filtering an array of file names To: Zsh Users Content-Type: multipart/alternative; boundary=001a11403008673023053da09086 --001a11403008673023053da09086 Content-Type: text/plain; charset=UTF-8 Thank you, Bart! This works perfectly. On Thu, Sep 29, 2016 at 9:18 AM, Bart Schaefer 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. > --001a11403008673023053da09086--