Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Change on stdout
- X-seq: zsh-users 14276
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: tartifola@xxxxxxxxx
- Subject: Re: Change on stdout
- Date: Fri, 31 Jul 2009 16:25:07 -0700
- Cc: zsh-users@xxxxxxxxxx
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=d200902; d=spodhuis.org; h=Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=svCeCqH1LA9lg32E0kp3kpBSW9Ufk2EJ/kY5g6DDU1ifUxV1oHOHraW0/hYsg1mFPV92KPLmw2yFdnTO+HITS0gNeOVWD63o69PD1rMqKkKSJRQtftbnIGHmSsJm0JutbZdlm964SkvPCyZNwSOXYuLyHYUT19rNmImRO3lynRI=;
- In-reply-to: <20090731175207.46af5c20.tartifola@xxxxxxxxx>
- Mail-followup-to: tartifola@xxxxxxxxx, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20090731175207.46af5c20.tartifola@xxxxxxxxx>
On 2009-07-31 at 17:52 +0200, tartifola@xxxxxxxxx wrote:
> I need to operate a transformation on the standard output
> of a command. The output is a list of numbers
>
> 1 5 8 ...
>
> and I like to have it transformed in
>
> a1=1,a2=5,a3=8,...
>
> Any suggestion?
% print '1 5 8 223' | read nums; n=1; print "a$n=${(ej:,a$((++n))=:)${(z)nums}}"
a1=1,a2=5,a3=8,a4=223
Note that string substitution ${var//pattern/replacement} only evaluates
the replacement once, but the arithmetic expansion on the array-joining
string is evaluated each time.
Regards,
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author