From: Janis Papanagnou on
pk wrote:
> Janis wrote:
>
>> BTW, I wonder why you said upthread
>>
>>>>> "I was thinking of something more shell-ish [...]"
>> and prefer shell loops and in this case quite bulky shell code.
>
> Don't get me wrong: awk is perfectly fine (no, I don't want to start the
> debate "shell loops vs. dedicated tools" again).

Don't get _me_ wrong... :-)

I'm not the least convinced about a radical "avoid shell loops" paradigm
and (mostly) abstain from those discussions. Though, just in this case,
it looked so apparently bad; an implicit awk loop and another subsequent
(and unnecessary in this case) shell loop, iterating more often over the
same data than necessary.

Janis

>
> [...]
From: pk on
Janis Papanagnou wrote:

>>>>>> "I was thinking of something more shell-ish [...]"
>>> and prefer shell loops and in this case quite bulky shell code.
>>
>> Don't get me wrong: awk is perfectly fine (no, I don't want to start the
>> debate "shell loops vs. dedicated tools" again).
>
> Don't get _me_ wrong... :-)
>
> I'm not the least convinced about a radical "avoid shell loops" paradigm
> and (mostly) abstain from those discussions. Though, just in this case,
> it looked so apparently bad; an implicit awk loop and another subsequent
> (and unnecessary in this case) shell loop, iterating more often over the
> same data than necessary.

I might even agree; my point was that, *having the code developed that way
for some reason (good or bad doesn't matter here) up to that point*, my
train of thought led me to ask the question I asked, because at that point I
was curious.
From: Janis Papanagnou on
pk wrote:
[...]
>
> I might even agree; my point was that, *having the code developed that way
> for some reason (good or bad doesn't matter here) up to that point*, my
> train of thought led me to ask the question I asked, because at that point I
> was curious.

I understood your thought, and I certainly didn't mean to offend you in any
way; you know that, I'm sure. :-)

Janis
From: pk on
Janis Papanagnou wrote:

> pk wrote:
> [...]
>>
>> I might even agree; my point was that, *having the code developed that
>> way for some reason (good or bad doesn't matter here) up to that point*,
>> my train of thought led me to ask the question I asked, because at that
>> point I was curious.
>
> I understood your thought, and I certainly didn't mean to offend you in
> any way; you know that, I'm sure. :-)

Sure, no worries :)

From: Javi Barroso on
On Mar 2, 10:09 am, pk <p...(a)pk.invalid> wrote:
> Janis Papanagnou wrote:
> >> works, but I have the impression that I'm overcomplicating it. However, I
> >> cannot find a simpler way. Any suggestion?
>
> > awk '{ print | "command" }
> >       /^END$/ { close("command") }'
>
> Yes, thanks (and to Bill). I was thinking of something more shell-ish rather
> than calling external commands in awk, but that'll do.
>
> Thank you!

what about using eval ?

eval "$(awk '
!/END/ { input=input$0"\n"; }
/END/ { printf "printf \"%s\" | command ;", input; input=""; }
')"

Or this command is an evil command ? :)
http://mywiki.wooledge.org/BashFAQ/048

Regards,