From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20284 invoked by alias); 21 Feb 2012 12:35:06 -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: 16776 Received: (qmail 23939 invoked from network); 21 Feb 2012 12:35:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.82.43 as permitted sender) Received-SPF: pass (google.com: domain of smblott@gmail.com designates 10.180.8.226 as permitted sender) client-ip=10.180.8.226; Authentication-Results: mr.google.com; spf=pass (google.com: domain of smblott@gmail.com designates 10.180.8.226 as permitted sender) smtp.mail=smblott@gmail.com; dkim=pass header.i=smblott@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=stuShOEhdO+G7pc0NEGvQkPwwRsniS7qF4QyfFry8cU=; b=DSownrmJMUquKYZxoSKqpptoADDdjEhIVatilgn1WcUR22IQyaNnkEmWGrC2c3Gxs3 tYNhet9qFpAwRQb4s4ohBs7HZg6sfp3Y9f0iBzLZNRQ8ut29A+AmpMrxIWacgTru9sOL /OgDe0N+yYnOGnXT8DEVOrPjunpRJS3Gr35FQ= Date: Tue, 21 Feb 2012 12:35:36 +0000 From: Stephen Blott To: zsh-users@zsh.org Subject: Re: somehow offtopic: looping filenames Message-ID: <20120221123536.GF23815@new.computing.dcu.ie> References: <20120220181650.GA11514@solfire> <120220110530.ZM450@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <120220110530.ZM450@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) On Mon, Feb 20, 2012 at 11:05:30AM -0800, Bart Schaefer wrote: > On Feb 20, 7:16pm, meino.cramer@gmx.de wrote: > } > } I habe a loop like this: > } > } for fn * > } do > } flac $fn > } done > } > } Unfortunately, some file have 'illegal' filenames > } which parts flac sees as unknown commmand options or as > } two file and the loop fails. > > Try this: > > for fn * > do > flac $fn:a > done > > The :a modifier expands $fn into a full path including removing any > mentions of "./" and "../". Think of it as a clean "$PWD/$fn". > > If you don't have a recent-enough zsh for :a to be supported or it is > for some reason important to avoid the full path, try > > flac ${${fn:h}-.}/${fn:t} > > If that's still confusing it because e.g. you have SH_WORD_SPLIT turned > on, wrap the expression in double quotes. > ---end quoted text--- Or: ls | tr '\n' '\0' | xargs -0 -n 1 flac -- If you're using Gnu xargs then you might need the -r/--no-run-if-empty flag too. Steve