Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: using parameter expansion sorting flags
- X-seq: zsh-users 16394
- From: Jérémie Roquet <arkanosis@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: using parameter expansion sorting flags
- Date: Thu, 22 Sep 2011 10:32:18 +0200
- Cc: Rory Mulvaney <rorymulv@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=G2VBkcPSwmGOpREUpCfPVFNth8l6wLnWjd+2k7y+hk0=; b=STxS6JnyxKtri11C0/FTizmvCRI3DXWTxFQF6VAbf4xqT/pVBCBqeFH9LDxnGs4Dtc Gsa7IQ/+ifzb+2nwOvtpd9GRRM9+5i0zuVUQRohDhZ1QKluQmMntQK8aX6gngCiPAxsj DWKrZQ7tFQCno1S5URNUtBE7o+1SezmSx7fWM=
- In-reply-to: <alpine.DEB.2.00.1109220143300.5262@MyComp.rgm-web.net>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.DEB.2.00.1109220143300.5262@MyComp.rgm-web.net>
Hi Rory,
2011/9/22 Rory Mulvaney <rorymulv@xxxxxxxxx>:
> 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
That's because you're mixing braces and globbing. What happens first is:
f.*.{Atop,Bbot}.pnm → f.*.Atop.pnm f.*.Btop.pnm
then only globbing is performed.
You could have used globbing only, and the “o” flag to have a sorted
array in the first place:
PNMFILES=( f.*.(Atop|Bbot).pnm(on) )
> 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.
PNMFILES2=${(on)PNMFILES}
Best regards,
--
Jérémie
Messages sorted by:
Reverse Date,
Date,
Thread,
Author