bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Gawk feature request - file list


From: david kerns
Subject: Re: [bug-gawk] Gawk feature request - file list
Date: Fri, 3 Feb 2017 08:06:54 -0700

On Fri, Feb 3, 2017 at 2:41 AM, Manuel Collado <address@hidden> wrote:
Can you use wildcards? Most windows ports of gawk do not expand wildcards in the shell, but inside the gawk executable. Quick test (warning, long line wrapped):

H:\WINDOWS\system32>gawk "{print ARGIND, FILENAME; len+=length(FILENAME)+1; nextfile} END{print len}" * * *
1 $winnt$.inf
...
7269 zipfldr.dll
84951

So the equivalent command line length, with wilcards expanded, would be 84951 characters.

HTH.

El 03/02/2017 9:06, Daniele Zanoli escribió:
[..]
Unfortunately I'm often using a Windows port of Gawk (I have to run it
on several PCs of my colleagues) and the windows shell command line is
only 32k characters (or bytes?) long...

I have built a kind of "IDE" which launches awk scripts over files in
order to make it simple to use also for non tech people but currently I
am limited on the max number of files I can handle.

Original Message  --------
Subject: Re: [bug-gawk] Gawk feature request - file list
From: address@hidden
To: address@hidden, address@hidden
Date: 1/2/2017, 15:57:18
[...]

Often I have to use gawk on a large number of files with a single
 execution of gawk (I have to compare some file contents) but it
is very easy to reach the maximum length of the shell command
line, since files are in different paths

So I think it would be useful (not only for me) a new command
line switch to specify a file that contains the names of the
files to process (e.g. gawk .. -list myfilelist.txt ...)

--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado


I'm not a Window's person by any means, but IIRC there was a (circa 1990) DOS command that would treat filenames that started w/ @ to be a file of file names ... going with that, you could modify Arnold's solution to:

$ cat filelist.awk
BEGIN {
  nARGC = 1
  for (i = 1; i < ARGC; i++) {
    if (ARGV[i] ~ /^@/) {
      filelist = substr(ARGV[i],2)
      while ((getline filename < filelist) > 0) {
        nARGV[nARGC++] = filename
      }
      close(filelist)
    } else {
      nARGV[nARGC++] = ARGV[i]
    }
  }
  for (i = 1; i < nARGC; i++) {
    ARGV[i] = nARGV[i]
  }
  ARGC = nARGC - 1
}

$ awk -f filelist.awk -f yourprogram.awk normalfile @fileoffiles

 

reply via email to

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