From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6266 invoked from network); 4 Jul 2005 12:07:17 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Jul 2005 12:07:17 -0000 Received: (qmail 11346 invoked from network); 4 Jul 2005 12:07:11 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Jul 2005 12:07:11 -0000 Received: (qmail 27526 invoked by alias); 4 Jul 2005 12:07:02 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9017 Received: (qmail 27512 invoked from network); 4 Jul 2005 12:07:01 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Jul 2005 12:07:01 -0000 Received: (qmail 10229 invoked from network); 4 Jul 2005 12:07:01 -0000 Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by a.mx.sunsite.dk with SMTP; 4 Jul 2005 12:06:56 -0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DpPiV-0000KT-W9 for zsh-users@sunsite.dk; Mon, 04 Jul 2005 14:06:28 +0200 Received: from 241.119-84-212.ippool.ndo.com ([212.84.119.241]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Jul 2005 14:06:27 +0200 Received: from david by 241.119-84-212.ippool.ndo.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Jul 2005 14:06:27 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@sunsite.dk From: zzapper Subject: Re: file names in arrays Date: Mon, 04 Jul 2005 13:06:04 +0100 Message-ID: References: <1050702205137.ZM4701@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 241.119-84-212.ippool.ndo.com X-Newsreader: Forte Free Agent 2.0/32.652 Sender: news X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Sat, 02 Jul 2005 20:51:37 +0000, wrote: >On Jun 30, 4:51pm, zzapper wrote: >} >} At the risk of being abused, RTFM etc etc >} >} Has anyone got a script where a number of file names resulting from >} say a find/grep are loaded into an array. > >Go to http://www.zsh.org/cgi-bin/mla/wilma/users and search for "keeper". > >} And then this array is looped thru with a promt deciding what might >} happen to these files, mv,rm,cp edit etc > >Isn't the answer to this the same as -- or awfully similar to, at any >rate -- the answer to your "Creating a Case statement dynamically" >thread from a couple of days earlier? > > > local file command target > find "$@" | keep > for file in $kept > do > PS3="Action on $file: " > target='' > select command in mv cp rm gvim > do > case $REPLY in > ((Q|q)*) break 2;; > (<1->) > case $command in > (cp|mv) vared -e -p "$command $file " target && > [[ -n $target ]] && $command $file $target > (?*) $command $file;; > (*) break;; > esac;; > (*) break;; > esac > done > done Bart, Yes it's similar to my previous thread, but hopefully more general. I'd found a useful solution, but didn't use arrays, so I ended up repeating operations. Your script above blows up for me on pick3:17: parse error near `$command' (the vared line) zsh 4.2.4 (i686-pc-cygwin) -- zzapper vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?" http://www.rayninfo.co.uk/tips/ vim, zsh & success tips