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

Re: Change on stdout



On Fri, Jul 31, 2009 at 1:39 PM, Erik Trulsson wrote:
> On Fri, Jul 31, 2009 at 01:31:57PM -0400, Matt Wozniski wrote:
>> On Fri, Jul 31, 2009 at 11:52 AM, <tartifola@xxxxxxxxx> wrote:
>> >
>> >
>> > Hi,
>> > 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?
>>
>> Use a tool like sed - this should work with any verion of sed ever
>> made, I believe:
>>
>> echo "1 2 3 4 5" | sed -e 's/[0-9][0-9]*/a&=&/g' -e 's/ /,/g'
>>
>> Of course, this has nothing whatsoever to do with zsh, but I can't
>> think of any interpretation of your question that would...
>
> That solution won't do what he asked for. ÂThe numbering of a1,a2, etc.
> looks like they should be independent of the numbers in the list.

Oops, indeed; I misread.  Still, though, I'd use perl for this over a
shell...  Unless this is something for a completer or some such, where
the cost of a fork should be avoided wherever possible.

~Matt



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