bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] -i infile unexpected behavior


From: Andrew J. Schorr
Subject: Re: [bug-gawk] -i infile unexpected behavior
Date: Sun, 15 Mar 2015 18:34:35 -0400
User-agent: Mutt/1.5.23 (2014-03-12)

Hi,

On Sun, Mar 15, 2015 at 11:43:28AM -0500, Ed Morton wrote:
> I fully understand that. My expectation is that a print in the END section
> would write to the last file read and more importantly I would expect `-i
> inplace ... ENDFILE` to behave like:
> 
>    $ cat file
>    foo
>    $ sed -i '$abar' file
>    $ cat file
>    foo
>    bar

Here is the equivalent in gawk:

bash-4.2$ echo foo > file
bash-4.2$ gawk -e '1; ENDFILE {print "bar"}' -i inplace file
bash-4.2$ cat file
foo
bar

I think that's not too shabby.

Regards,
Andy



reply via email to

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