From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8186 invoked by alias); 16 Apr 2016 14:55:22 -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: 21451 Received: (qmail 27023 invoked from network); 16 Apr 2016 14:55:21 -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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 Subject: Re: [[ -f ]] and filename generation To: zsh-users@zsh.org References: <20160416113133.GA10973@solfire> From: Eric Cook Message-ID: <57125253.1090409@gmx.com> Date: Sat, 16 Apr 2016 10:55:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160416113133.GA10973@solfire> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:DyEuWnncRxffMWBrnxfGgm4YTr0p1ZeONwLQWdrRms1LJHI1Sbf g941G7NHDkzugn4XOw84rZWKkZV3By8ceqxFpgvC9DRG+qSkHWUmhlv/YcgZJJHbiO1MUWd hkE5IsFeDNEX7j+Gqv9wZqPTR9hvWjZiV0sMPRxWUJkoWGPOtm1bYCT3ctGHxphBeYyS06z t6Po/SnDINVr0Qb+8ZHSA== X-UI-Out-Filterresults: notjunk:1;V01:K0:1k8rDYl1Rxs=:JIyazuvQ67k1SOSEqif01t yspVBy3S6OuL/tWPNNjBplbcvOtCHQgXJkm7VO+hs997kFI7KUGyIHg0AzvyCV0p6fiJBFdCX Q9R2YLyQWPiE4tFpip7sSsjEkikl8tB3yE/W6xnfRk2orqzvjkFsIBZ80pzDQhNLBWJipXE5H QDC7z125Mqv8LOacIvsfNEgtTRMlh1pPU8gwKW/VcvkKhsxBhnr/d0QT5gJZqi5uaomZH1oxV GMdgvBzCBrL7gpopyeE0jahkPa2otbqplaKSjFrjujAJJa1EdxLZ3FtV1tn2Y9I8m66mHtRtt MDTpvP+LHfMpJThgfvX6UiOqgcMDxLtsxpjaPih1761XhlGFQi0V/6gTKp7DiNKUGliw+pfTG Qm9VgeAolXMs0Rww1BjbA5vinUw3Ydqd+h7/1FVMQiYT2G0tW40NgM4atRCwSNDmwmmGs/pk9 XxX7xK+TBGQUdl+LHvEpXCELqaJHSRiHLfKTn0sewM04RpRXAIvUDDVXSHo7cgkdceP+wlDki TplEArSagpAZVSoirYsvyxYgjagEBfzUWE/mR1+O4fR8UQv3rz+Sx4FX4erKJyEz24imGs677 pwIsCIncFHL0IOz8ZbDwPVCAXHPj4umQ/7sTy6Rsd1lPZGd4Z+elvlDYhgXRBr/8EK7yTAxDT 2bmNvjnzelV9nyrVPiA0jdiFnKxU8Q92zAxPFTrW/2JilO62a6mNt8v5rfGd+ZhhQefW3sYLh k9hNM6NNlx1gOCDgxJgYNc1GD0TX9HsF7kOvEy1+JP+nhVuygjOrSoRPi9HZ9/Fi+jqmW6AMi mucFMe8 On 04/16/2016 07:31 AM, Meino.Cramer@gmx.de wrote: > Hi, > > A script I am writing is reading filenames from a list. > These filenames not complete. > > Example: > > On disk: > filename.ext1.ext2 > > In the list: > filename > or > filename.ext > > I want to check for the existing of the files in the list on disk with > a construct like this > > if [[ -f $FILEFROMLIST ]] ; then > > # do something more useful here > > fi > > I know, that are different approaches to this problem (for example > reading the filenames from disk into an array and process those) but > I am interested in getting this -f thingy to run. > > I tried variation of > if [[ -f "$FILEFROMLIST*" ]] ; then .... fi > with extendedglob set...but with no success. > > Is there any way to get this "-f" thingy to work? > > Thank you very much in advance for any help! > Best regards, > Meino > > > > > Filename generation does not happen inside the [[ normally. In zsh >= 5.0.5, you can force globbing to happen by using the glob qualifier #q. (requires extendedglob to be enabled) % [[ -f *(#q.) ]]; echo $? 1 Since globbing can match multiple files, [[ -f will fail since more than one file matches the glob. So you can also use the new qualifier Y to limit the results to the first match. % [[ -f *(#qY1.) ]]; echo $? 0