[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: |
Douglas Charles Duckworth |
Subject: |
Re: awk 5.2.2 - Inplace Syntax Error When File Contains Dot |
Date: |
Wed, 25 Oct 2023 15:38:50 +0000 |
I read the manual and now it works!
https://www.gnu.org/software/gawk/manual/gawk.html#AWKPATH-Variable
https://www.gnu.org/software/gawk/manual/gawk.html#AWKLIBPATH-Variable
[~]$ echo $AWKLIBPATH
/software/centos7/awk/5.2.2/lib/gawk
[~]$ echo $AWKPATH
/software/centos7/awk/5.2.2/share/awk
Thank you!
------- Original Message -------
On Wednesday, October 25th, 2023 at 10:27 AM, Douglas Charles Duckworth
<quackmaster@protonmail.com> wrote:
> Thank you!
>
> I compiled gawk myself. When I run:
>
> awk -i /software/centos7/awk/5.2.2/share/awk/inplace.awk '1;/whatis/{ print "
> "; print "module use /cm/local/modulefiles"}' file
>
> I get:
>
>
> awk: /software/centos7/awk/5.2.2/share/awk/inplace.awk:30: error: cannot open
> shared library `inplace' for reading: No such file or directory"
>
> Line 30 of "inplace.awk:30" does:
>
> @load "inplace"
>
> I am confused as I set LD_LIBRARY_PATH to traverse both "lib" and "lib/gawk":
>
> [~]$ echo $LD_LIBRARY_PATH
> /software/centos7/awk/5.2.2/lib:/software/centos7/awk/5.2.2/lib/gawk
>
> Which contains the shared library "inplace.so":
>
> [~]$ ls -tlr /software/centos7/awk/5.2.2/lib/gawk
> total 441K
> -rwxr-xr-x 1 root root 120K Oct 19 14:16 filefuncs.so
> -rwxr-xr-x 1 root root 27K Oct 19 14:16 fnmatch.so
> -rwxr-xr-x 1 root root 28K Oct 19 14:16 fork.so
> -rwxr-xr-x 1 root root 34K Oct 19 14:16 inplace.so < ---- HERE
> -rwxr-xr-x 1 root root 28K Oct 19 14:16 intdiv.so
> -rwxr-xr-x 1 root root 22K Oct 19 14:16 ordchr.so
> -rwxr-xr-x 1 root root 28K Oct 19 14:16 readdir.so
> -rwxr-xr-x 1 root root 29K Oct 19 14:16 readfile.so
> -rwxr-xr-x 1 root root 25K Oct 19 14:16 revoutput.so
> -rwxr-xr-x 1 root root 28K Oct 19 14:16 revtwoway.so
> -rwxr-xr-x 1 root root 47K Oct 19 14:16 rwarray.so
> -rwxr-xr-x 1 root root 28K Oct 19 14:16 time.so
>
>
> Any more suggestions are greatly appreciated. I normally use sed for this
> type of task but I wanted to become more familiar with awk.
>
> Thanks.
>
>
>
> ------- Original Message -------
> On Thursday, October 19th, 2023 at 5:30 PM, Neil R. Ormos
> ormos-gnulists17@ormos.org wrote:
>
>
>
> > 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