bug-gawk
[Top][All Lists]
Advanced

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

Re: gawk 4.0.2 issue - "fatal: not enough arguments to satisfy format st


From: Neil R. Ormos
Subject: Re: gawk 4.0.2 issue - "fatal: not enough arguments to satisfy format string"
Date: Sun, 8 Mar 2020 18:47:35 -0500 (CDT)

david kerns wrote:
> address@hidden> wrote:

>> I have two text files a and b with only one byte different.
>> The last character of the second line in file a is letter "o" in lower
>> case while in the same location in file b is letter "A" in upper case. [...]

>> '{for(i>0;i<=NR;i++)a[i]=$0}END{for(j=0;3*j+1<i;j++){printf"|";for(k=1;k<=3;k++)printf
>> a[3*j+k]"|";printf"\n"}}'
>> |1|awk: cmd. line:1: (FILENAME=- FNR=6) fatal: not enough arguments to
>> satisfy format string
>> `2% o|' 
>> ^ ran out for this one

> The real problem is your 2nd printf has no
> format string (the first argument to printf),
> and then the argument you pass contains a % [...]

The 2nd printf does have a format string.  It's the expression:

  a[3*j+k]"|"

The original poster may not be aware that "% o" is a valid printf format 
specification, where the space character is a flag, and therefore printf is 
expecting an argument to be converted with %o treatment.

The reason no error was produced when the program was run against file b is 
because the "A" in "% A" is not a valid conversion specifier in the older 
version of Gawk that the poster is using, so no argument was expected.  If the 
poster were running a newer Gawk where "% A" a recognized conversion spec, an 
argument would be required when running his program against file b also.



reply via email to

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