bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] how to close pipe?


From: Aharon Robbins
Subject: Re: [bug-gawk] how to close pipe?
Date: Mon, 24 Nov 2014 23:24:41 +0200
User-agent: Heirloom mailx 12.5 6/20/10

Hello.

> From: "frank ernest" <address@hidden>
> To: address@hidden
> Date: Mon, 24 Nov 2014 20:15:13 +0100
> Subject: Re: [bug-gawk] how to close pipe?
> Status: R
>
> > cmd = "grep \"" $1 "\" fn.txt"; cmd | getline var; close(cmd)
> > 
> > But that's really just about the most terrible way of doing whatever
> > you're trying to there (and you're still missing
> > posssible multi-line output from grep). It's very likely that the
> > whole task is solvable entirely with awk alone.
>
> No, that does not help.

I suspect it would.

> Here is the complete gawk script

Reformatting for readability:

BEGIN { f = "" }

{
        if (f != $1) {
>>>>            cmd = "grep -E \"" $1 "\" fn.txt" | getline var
                close(cmd)
                system("echo " $1 " >> desc.txt; grep -A 100 \"Description:\" 
'\''" var "/control'\'' >> desc.txt; echo >> desc.txt;")
                f = $1
        }
}

Please try changing the marked line to:

                cmd = "grep -E \"" $1 "\" fn.txt"
                cmd | getline var

I think that will make a difference.

Thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]