From: Anthony Charles <antho.charles@gmail.com>
To: zsh-users@zsh.org
Subject: Re: using parameter expansion sorting flags
Date: Thu, 22 Sep 2011 09:59:36 +0200 [thread overview]
Message-ID: <20110922075936.GE4542@layslair.ath.cx> (raw)
In-Reply-To: <alpine.DEB.2.00.1109220143300.5262@MyComp.rgm-web.net>
Hi,
It works with o and n flags :
% a=( f.0009.Atop.pnm f.0010.Atop.pnm f.0011.Atop.pnm
f.0012.Atop.pnm f.0009.Bbot.pnm f.0010.Bbot.pnm f.0011.Bbot.pnm)
% print -l $a
f.0009.Atop.pnm
f.0010.Atop.pnm
f.0011.Atop.pnm
f.0012.Atop.pnm
f.0009.Bbot.pnm
f.0010.Bbot.pnm
f.0011.Bbot.pnm
% print -l ${(on)a}
f.0009.Atop.pnm
f.0009.Bbot.pnm
f.0010.Atop.pnm
f.0010.Bbot.pnm
f.0011.Atop.pnm
f.0011.Bbot.pnm
f.0012.Atop.pnm
% print -l ${${(on)a}[2]}
f.0009.Bbot.pnm
% PNMFILES2=( ${(on)a} )
% print -l ${PNMFILES2[2]}
f.0009.Bbot.pnm
--
Anthony CHARLES
On Thu, Sep 22, 2011 at 01:46:20AM -0500, Rory Mulvaney wrote:
> Hello,
>
> I have a few filenames that I put into an array with:
>
> PNMFILES=( f.*.{Atop,Bbot}.pnm )
>
> the ordered contents of this array become:
>
> f.0009.Atop.pnm f.0010.Atop.pnm f.0011.Atop.pnm f.0012.Atop.pnm
> f.0009.Bbot.pnm f.0010.Bbot.pnm f.0011.Bbot.pnm
>
> Now I can't figure out how to order them in an array, using the parameter
> expansion sorting flags n and o, as:
>
> f.0009.Atop.pnm f.0009.Bbot.pnm f.0010.Atop.pnm f.0010.Bbot.pnm
> f.0011.Atop.pnm f.0011.Bbot.pnm f.0012.Atop.pnm
>
> Also I'd like the resulting resorted array PNMFILES2 to be such that:
>
> echo ${PNMFILES2[2]}
>
> yields:
>
> f.0009.Bbot.pnm
>
> rather than some single character.
>
> Thanks and regards again,
> Rory
next prev parent reply other threads:[~2011-09-22 8:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 6:46 Rory Mulvaney
2011-09-22 7:59 ` Anthony Charles [this message]
2011-09-22 12:23 ` Rory Mulvaney
2011-09-22 8:32 ` Jérémie Roquet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110922075936.GE4542@layslair.ath.cx \
--to=antho.charles@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).