From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24768 invoked by alias); 25 Mar 2011 22:04:18 -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: 15899 Received: (qmail 8094 invoked from network); 25 Mar 2011 22:04:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110325150350.ZM30913@torch.brasslantern.com> Date: Fri, 25 Mar 2011 15:03:49 -0700 In-reply-to: <9861b13e6828d43041a5b489f016664a.squirrel@gameframe.net> Comments: In reply to nix@myproxylists.com "How to add string to end of each array element without loops" (Mar 25, 11:32pm) References: <9861b13e6828d43041a5b489f016664a.squirrel@gameframe.net> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: How to add string to end of each array element without loops MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Mar 25, 11:32pm, nix@myproxylists.com wrote: } Subject: How to add string to end of each array element without loops } } a=(1 2 3) } a=(foo$^a[@]) } } print -l "${(@n)a}" If $^a[@] works, then you don't need the subscript, either: a=(foo$^a) Futhermore you don't need the quotes and (@) in the print expression: print -l ${(n)a} } foo1 } foo2 } foo3 } } I would like to get the following output instead: } } 1foo } 2foo } 3foo I'm not understanding what you're asking. Either this is as easy as a=(1 2 3) a=(${^a}foo) # braces needed to distinguish $a from $afoo or you've already got (foo$^a) and you're asking how to change "foo?" into "?foo" for the whole array setopt extendedglob a=(${a/(#b)foo(<->)/$match[1]foo}) or you mean something else entirely. Can you elaborate? --