Reputation: 149
I get a syntax error:
/usr/xpg4/bin/awk: file "./test.awk": line 64: syntax error
Context is:
>>> printf (", %s", date_value ( $3, fmt_yyyymmdd ) ); <<<
The code fragments are:
fmt_yyyymmdd="yyyymmdd";
printf (", %s", date_value ($22, fmt_yyyymmdd ) );
...
function date_value(string, format)
{
return "20150101";
}
I am not able to understand where the syntax error is. A very similar statement (with one parameter only) produces no syntax error and works correctly.
printf (", %s", char_value ( $2) );
For me it seems that awk either does not allow calling a user defined function with a parameter being a user defined variable or literal or calling a user defined function with more than one parameter. I am unfortunately not proficient in awk.
Upvotes: 1
Views: 358
Reputation: 36262
I think the problem is how you call the function. In user-defined functions it cannot exist any space between the name and the parameters, use:
printf (", %s", date_value($22, fmt_yyyymmdd ) );
Upvotes: 2