Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Change on stdout



On Fri, Jul 31, 2009 at 03:40:12PM -0400, Omari Norman wrote:
> On Fri, Jul 31, 2009 at 05:52:07PM +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,...
> 
> This is inelegant (like my knowledge of the shell) but should work.

Whoops, that should be:

$ nums=$(your_command)
$ numArray=( ${=nums} )
$ for (( n = 1; n <= ${#numArray}; n++)); do
echo -n "a${n}=${numArray[$n]},"
done; echo

Forgot the "do" in there, and the semicolon after the "done".

-- 
Why wait? Call now!



Messages sorted by: Reverse Date, Date, Thread, Author