|
From: | Manuel Collado |
Subject: | Re: [bug-gawk] in-place edit request |
Date: | Wed, 02 Jan 2013 09:12:42 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
El 02/01/2013 0:33, Andrew J. Schorr escribió:
On Mon, Dec 31, 2012 at 10:18:32PM +0200, Aharon Robbins wrote:Now someone in the community, who thinks this feature is worthwhile, needs to step up to the plate and do the work.I just whipped up a proof of concept. It is attached. It seems to work on linux. For example, these commands do the right thing: bash$ gawk -i inplace '{sub(/foo/, "bar"); print}' /tmp/tfile bash$ gawk -i inplace -v "INPLACE_SUFFIX=.bak" '{sub(/foo/, "bar"); print}' /tmp/tfile [....]
Thoughts?
It seems useful. And probably will make Ed happy.Just an additional thought. The -i behavior of Perl and Ruby, is usually combined with an additional -p flag that makes the final 'print' statement unnecessary. I.e., in gawk it would implicitly add a final '{print}' rule to the whole awk program. This -p flags makes sense by itself, not only as a -i companion.
I assume this feature cannot be implemented with the current extension mechanism, so it would be probably better to disregard it. But anyway I think it is worth just to mention it (perhaps in the inplace extension documentation).
Regards, -- Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
[Prev in Thread] | Current Thread | [Next in Thread] |