• GNU Awk - inplace editing

    From Janis Papanagnou@21:1/5 to All on Fri May 23 07:28:20 2025
    In GNU Awk I was looking for the in-place option (similar to sed -i).
    I thought there once was some _simple_ option usable from the command
    line. (Or am I misremembering?)

    The manual now suggests to use a GNU Awk "inplace" _Extension_ for that
    gawk -i inplace ...
    and
    gawk -i inplace -v inplace::suffix=.bak ...
    respectively.

    That's not exactly as simple to use as, say,
    gawk -i ...
    and
    gawk -i.bak
    so I suppose there's a reason for the added complexity in the handling.

    Does anyone know that reason or remember a rationale? - I don't recall
    any discussions about that...

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Janis Papanagnou on Fri May 23 06:02:08 2025
    On 2025-05-23, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    In GNU Awk I was looking for the in-place option (similar to sed -i).
    I thought there once was some _simple_ option usable from the command
    line. (Or am I misremembering?)

    The the "-i inplace" thing was introduced in May 2013, by
    the GNU Awk 4.1.0 release. So, almost exactly twelve years ago now.

    The release notes do not mention that any existing inplace
    mechanism was being replaced. It mensions only sed -i.

    However, like you, I also seem to have same strange memory that there
    had been some earlier inplace mechanism that was deprecated.
    It might have been something very short-lived?

    The manual has a Feature History, but that is unreliable;
    since it doesn't mention the -i inplace feature either,

    Btw, spotted something mildly funny in the gawk git:

    commit cce5115e21db1702e0617afdca36633e7e2c9eae (tag: gawk-2.11.1)
    Author: Arnold D. Robbins <arnold@skeeve.com>
    Date: Thu Jul 15 23:24:47 2010 +0300

    Move to gawk 2.11.1 as found on Walnut Creek CD-ROM.

    commit 3697ec5ca140f686643d204a54181a5ddbf9a799 (tag: gawk-2.11)
    Author: Arnold D. Robbins <arnold@skeeve.com>
    Date: Thu Jul 15 23:12:49 2010 +0300

    Moved to gawk 2.11.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Kenny McCormack on Fri May 23 08:58:33 2025
    On 2025-05-23, Kenny McCormack <gazelle@shell.xmission.com> wrote:
    In article <100p11m$3uh3m$1@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    In GNU Awk I was looking for the in-place option (similar to sed -i).
    I thought there once was some _simple_ option usable from the command
    line. (Or am I misremembering?)

    The manual now suggests to use a GNU Awk "inplace" _Extension_ for that
    gawk -i inplace ...
    and
    gawk -i inplace -v inplace::suffix=.bak ...
    respectively.

    That's not exactly as simple to use as, say,
    gawk -i ...
    and
    gawk -i.bak
    so I suppose there's a reason for the added complexity in the handling.

    Does anyone know that reason or remember a rationale? - I don't recall
    any discussions about that...

    I've explained this a few times over the years (in this newsgroup).

    There was never a "-i" option in Gawk that meant "inplace" (and there never will be).

    The key to understanding this is to understand that (in Gawk), the "i" in "-i" does not stand for "inplace". It stands for "include".

    Once you understand that, all becomes clear.

    Sure, but, interestingly, just like Janis, I also seem to have a false,
    memory of there having been some other inplace mechanism that was
    replaced by the -i inplace include (not necessarily a -i option). There
    is no evidence of any such in the available materials, though.

    We might have both been duped by something unclear someone said once,
    (perhaps here)?

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to janis_papanagnou+ng@hotmail.com on Fri May 23 08:22:05 2025
    In article <100p11m$3uh3m$1@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    In GNU Awk I was looking for the in-place option (similar to sed -i).
    I thought there once was some _simple_ option usable from the command
    line. (Or am I misremembering?)

    The manual now suggests to use a GNU Awk "inplace" _Extension_ for that
    gawk -i inplace ...
    and
    gawk -i inplace -v inplace::suffix=.bak ...
    respectively.

    That's not exactly as simple to use as, say,
    gawk -i ...
    and
    gawk -i.bak
    so I suppose there's a reason for the added complexity in the handling.

    Does anyone know that reason or remember a rationale? - I don't recall
    any discussions about that...

    I've explained this a few times over the years (in this newsgroup).

    There was never a "-i" option in Gawk that meant "inplace" (and there never will be).

    The key to understanding this is to understand that (in Gawk), the "i" in
    "-i" does not stand for "inplace". It stands for "include".

    Once you understand that, all becomes clear.

    --
    Senator Marsha Blackburn (R-TN), who sits on the Judiciary Committee, said it was
    "extremely inappropriate" for the president to nominate a Supreme Court justice on a
    day ending with the letter "Y", and she said that "Biden is putting the demands of the
    radical progressive left ahead of what is best for our nation."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Kaz Kylheku on Fri May 23 16:08:10 2025
    On 23.05.2025 10:58, Kaz Kylheku wrote:
    On 2025-05-23, Kenny McCormack <gazelle@shell.xmission.com> wrote:
    In article <100p11m$3uh3m$1@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    In GNU Awk I was looking for the in-place option (similar to sed -i).
    I thought there once was some _simple_ option usable from the command
    line. (Or am I misremembering?)

    The manual now suggests to use a GNU Awk "inplace" _Extension_ for that
    gawk -i inplace ...
    and
    gawk -i inplace -v inplace::suffix=.bak ...
    respectively.

    That's not exactly as simple to use as, say,
    gawk -i ...
    and
    gawk -i.bak
    so I suppose there's a reason for the added complexity in the handling.

    Does anyone know that reason or remember a rationale? - I don't recall
    any discussions about that...

    I've explained this a few times over the years (in this newsgroup).

    It's no disrespect; my memory is just limited.


    There was never a "-i" option in Gawk that meant "inplace" (and there never >> will be).

    The key to understanding this is to understand that (in Gawk), the "i" in
    "-i" does not stand for "inplace". It stands for "include".

    No doubt. - What I wanted to say is that I thought there was a _simple_
    option "like -i" (although, before 'include' times, it could have also
    been '-i').


    Once you understand that, all becomes clear.

    Unfortunately, the question about the rationale for using the GNU Awk
    Extension mechanism - which was my original question - isn't answered
    by that or any clearer.


    Sure, but, interestingly, just like Janis, I also seem to have a false, memory of there having been some other inplace mechanism that was
    replaced by the -i inplace include (not necessarily a -i option).

    I never needed the "inplace" feature with Awk[*] so my (wrong) memories
    were not based on practical experience; practical experience would have
    lead to a more enduring (likely correct) memory, I'd expect.

    [*] On shell level I use a two-step process with a temporary, to make processing typically also a bit more reliable.

    There is no evidence of any such in the available materials, though.

    We might have both been duped by something unclear someone said once, (perhaps here)?

    It's no biggie, I just wanted some clarity.

    Thanks for the investigation.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mack The Knife@21:1/5 to janis_papanagnou+ng@hotmail.com on Sun May 25 04:00:02 2025
    In article <100p11m$3uh3m$1@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    In GNU Awk I was looking for the in-place option (similar to sed -i).
    I thought there once was some _simple_ option usable from the command
    line. (Or am I misremembering?)

    You are misremembering.

    The manual now suggests to use a GNU Awk "inplace" _Extension_ for that
    gawk -i inplace ...
    and
    gawk -i inplace -v inplace::suffix=.bak ...
    respectively.
    ....
    Does anyone know that reason or remember a rationale? - I don't recall
    any discussions about that...

    It was done with an extension because the maintainer saw no
    reason to add Yet Another Option and Still More Code That Would
    See Very Little Use into the main core of gawk.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Ed Morton on Mon May 26 02:11:38 2025
    On 25.05.2025 22:27, Ed Morton wrote:
    On 5/23/2025 12:28 AM, Janis Papanagnou wrote:
    In GNU Awk I was looking for the in-place option (similar to sed -i).
    I thought there once was some _simple_ option usable from the command
    line. (Or am I misremembering?)

    The manual now suggests to use a GNU Awk "inplace" _Extension_ for that
    gawk -i inplace ...
    and
    gawk -i inplace -v inplace::suffix=.bak ...
    respectively.

    That's not exactly as simple to use as, say,
    gawk -i ...
    and
    gawk -i.bak
    so I suppose there's a reason for the added complexity in the handling.

    Does anyone know that reason or remember a rationale? - I don't recall
    any discussions about that...

    The somewhat lengthy discussion at https://lists.gnu.org/archive/html/bug-gawk/2012-12/msg00046.html may
    (or may not) be useful.

    Hi Ed,

    this is very valuable, and more than I expected; it has some technical discussions, it shows the "feelings", opinions and rationales, and all
    around it. Also the contained link to the Usenet discussions from that
    time (where we participated, obviously) was a good addition, and also
    to recall the thoughts, wishes and doubts we had back then. - Thanks!

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)