From: pk on 3 Mar 2010 04:24 Javi Barroso wrote: > 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 Well, it's evil if you don't have any control over the contents of whatever you apply it on (eg user input). But if you know your data and use it consciounsly, it's actually very useful. In this specific case, I don't think eval provides a significant benefit over the other solutions (and make the code more complicated because of all the levels of quoting going on). Thank you!
First
|
Prev
|
Pages: 1 2 3 4 Prev: Escaping regexp meta characters Next: wget, forms, password, cookies |