Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: joining array elements
- X-seq: zsh-users 9828
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx (Zsh users list)
- Subject: Re: joining array elements
- Date: Thu, 12 Jan 2006 11:54:48 +0000
- In-reply-to: <0852320A-7790-45A1-9BE5-8B7AB27BD107@xxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <36947C4E-7C19-4BB5-A43B-EC8D3EF0713A@xxxxxxxxxxxxxxxxxxxx> <1060112014126.ZM717@xxxxxxxxxxxxxxxxxxxxxxx> <6DC50D24-618F-4531-BA06-0F31570283C1@xxxxxxxxxxxxxxxxxxxx> <A61FA50A-E761-49CC-B86C-206C54A8AE61@xxxxxxxxxxxxxxxxxxxx> <EXCHANGE0301obk3dc0000028fa@xxxxxxxxxxxxxxxxxx> <0852320A-7790-45A1-9BE5-8B7AB27BD107@xxxxxxxxxxxxxxxxxxxx>
Wataru Kagawa wrote:
> Hi Peter,
>
> Thank you for the tip. I would like to place the expansion into a
> variable, however, I am having a trouble.
>
> % usernames=( Bob Sara Tim )
> % print -R ${(j:[return]:)~~usernames}
> Bob[return]Sara[return]Tim
>
> However,
>
> % foo=$( printf '%s\n' David Matt ${(j:[return]:)~~usernames} )
> % echo $foo
What effect are you trying to achieve? The command you show does
exactly what I expect it to. Do you mean you want David and Matt added
in the same way and the result put in foo?
usernames2=(David Matt $usernames)
foo=${(j:[return]:)~~usernames2}
Or do you mean you want the same effect as you get when outputting David
and Matt using printf, but with all the names, so that foo ends up being
joined with newlines?
foo=${(F)usernames2}
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Your mail client is unable to display the latest news from CSR. To access our news copy this link into a web browser: http://www.csr.com/email_sig.html
Messages sorted by:
Reverse Date,
Date,
Thread,
Author