help-gawk
[Top][All Lists]
Advanced

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

Re: awk 5.2.2 - Inplace Syntax Error When File Contains Dot


From: Neil R. Ormos
Subject: Re: awk 5.2.2 - Inplace Syntax Error When File Contains Dot
Date: Thu, 19 Oct 2023 17:30:42 -0500 (CDT)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

Douglas Charles Duckworth via Help-gawk wrote:

> Hi,
> 
> awk can parse a file and print results to stdout fine but when I try the 
> inplace module it fails if the file contains dot.
> 
> My version:
> 
> [~]$ gawk -V
> GNU Awk 5.2.2, API 3.2, PMA Avon 8-g1
> Copyright (C) 1989, 1991-2023 Free Software Foundation.
> The file:
> 
> [~]$ cat file
> test data
> 
> whatis
> container.sif
> 
> Success:
> 
> [~]$ awk '1;/whatis/{ print " "; print "module use /cm/local/modulefiles"}' 
> file
> 
> test data
> 
> whatis
> 
> module use /cm/local/modulefiles
> container.sif
> 
> Failure:
> 
> [~]$ gawk -i file '1;/whatis/{ print " "; print "module use 
> /cm/local/modulefiles"}'
> gawk: file:5: container.sifgawk: file:5: ^ syntax error
> 
> This seems to occur whenever the input file contains "."

The "-i file" in your failure case causes gawk to expect to find awk (gawk) 
source code in "file".  The contents of "file" don't appear to be cognizable 
awk source code.

If you are trying to use the gawk inplace extension, there is an example of how 
to do that in the manual. 

See, 17.7.4 Enabling In-Place File Editing, 
 
  
<https://www.gnu.org/software/gawk/manual/html_node/Extension-Sample-Inplace.html>

On some systems, the example program might be installed here (YMMV):

  /usr/share/awk/inplace.awk



reply via email to

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