bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] in-place edit request


From: Ed Morton
Subject: Re: [bug-gawk] in-place edit request
Date: Sun, 23 Dec 2012 10:52:20 -0600
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0

Arnold - thanks for getting back to me. I responded at comp.lang.awk. The shell script solution is horrible. If I want to change "foo" to "bar" for all the files in my directory I have these choices:

   find . -type f -exec sed -i 's/foo/bar/g' {} \;

find . -type f -exec sh -c (awk '{gsub(/foo/,"bar"}1' {} > tmp/tmp$$ && mv /tmp/tmp$$ {} \;')

and I'm sure I got the syntax of that shell+awk solution wrong.

It's just too lengthy, complicated, and error prone and even for more involved scripts it makes people choose complicated sed solutions over trivial awk solutions.

    Ed.

On 12/23/2012 4:29 AM, Aharon Robbins wrote:
Hi Ed.

Date: Thu, 20 Dec 2012 17:12:48 -0600
From: Ed Morton <address@hidden>
To: address@hidden
Subject: [bug-gawk] in-place edit request

Can we get an in-place edit function for gawk like
sed, perl, ruby., etc. have with their "-i" option? It
should behave like perl does. See the discussion at
https://groups.google.com/forum/#!topic/comp.lang.awk/ORwDyRRBcHE.

Regards,

      Ed Morton
Thank you for your note.

Janis Papanagnou and Mauel Collado both raised a number of questions as
to how this would work and even if it's a good idea.

First, the proposal is not well defined. "Just do what perl does" isn't
good enough. Second, I don't think it's even a good idea. It would
complicate the code considerably, and I think that the general use case
can be solved using a shell script (as I wrote in comp.lang.awk).

Thanks,

Arnold





reply via email to

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