Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: can I control brace expansion's "sort"/"display" order?
- X-seq: zsh-users 13174
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: can I control brace expansion's "sort"/"display" order?
- Date: Sun, 31 Aug 2008 11:41:54 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=ewmNj8FCIowNZurFG1ZCq6BJbfZj8IaHMl8ugRy+PVY=; b=mwghP0qi6D8OngOhOT7XU18YbUH2Y6HiCqlN4U5v5BbFfIIvUNgr/+wLqPcTLaAwJT u+h99c5ziIuw8vZmtdTZqcwJP9W5eOIhbjfC898zb2x5MaD8ZyQveFPL66B6GKI6SSNc 14DrimQJM28y+3qdbJfSMv7/RCuSzDao6HfkA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=BiRUWKP7VZM5letccLYe7wBsji6mWFW/jtJNR2UBYoav2QzMEucsYe1OFL1Jjdu1OB gN22WknB2uAOow45bIzLNLnH4wt7hn4+XOxiO/B3wQgRdLvgm6XwaJDHsHATJT4DU61I Wuzy2Udr4wknLdFbn4l1T2tIo7ctWyvD3qG8Y=
- In-reply-to: <18618.26046.529685.352779@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <18618.26046.529685.352779@xxxxxxxxxxx>
2008/8/31 Eric De Mund <ead@xxxxxxxxx>:
> Hello,
>
> Can I control brace expansion's "sort" or "display" order?
>
> For instance this zsh echo results in this output:
>
> % echo {white,black}{bird,fish}{21..24} | tr ' ' '\n'
> # current output order
> whitebird21
> whitebird22
> whitebird23
> whitebird24
> whitefish21
> whitefish22
> whitefish23
> whitefish24
> blackbird21
> blackbird22
> blackbird23
> blackbird24
> blackfish21
> blackfish22
> blackfish23
> blackfish24
> %
>
> But what if instead of this order I wanted the last brace to cycle most
> slowly, followed by the first, followed by the second, like so:
>
> % echo {white,black}{bird,fish}{21..24} | tr ' ' '\n'
> # desired output order
> whitebird21
> whitefish21
> blackbird21
> blackfish21
> whitebird22
> blackbird22
> whitefish22
> blackfish22
> whitebird23
> whitefish23
> blackbird23
> blackfish23
> whitebird24
> whitefish24
> blackbird24
> blackfish24
> %
>
> Is there any way to accomplish this?
>
> My problem is that I'm trying to get files added to a zip archive in a
> particular order, and this order is neither brace expansion sort/display
> order nor lexicographical order.
You can probably do it with some for-looping, like
setopt shortloops
% for a in white black; for b in fish bird; for c in {21..24}; echo $a$b$c
whitefish21
whitefish22
whitefish23
whitefish24
whitebird21
whitebird22
whitebird23
whitebird24
blackfish21
blackfish22
blackfish23
blackfish24
blackbird21
blackbird22
blackbird23
blackbird24
Now you can just swap the order of the loops
% for b in fish bird; for a in white black; for c in {21..24}; echo $a$b$c
whitefish21
whitefish22
whitefish23
whitefish24
blackfish21
blackfish22
blackfish23
blackfish24
whitebird21
whitebird22
whitebird23
whitebird24
blackbird21
blackbird22
blackbird23
blackbird24
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author