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

Re: Change on stdout



On Friday 31 July 2009 22:57:11 Matt Wozniski wrote:
> 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

Indeed there are even fewer fork() because it's likely to do the processing 
via shell builtins which don't fork at all. Not even one for forking perl and 
the builtins may be less memory consumptive since the perl interpreter 
consumes memory and it may not be already in the filecache so forking takes 
even longer.

Attachment: signature.asc
Description: This is a digitally signed message part.



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