I can't define user function in awk.
I get error:
Man pages state:
So where is the problem?
Code:
#!/bin/sh
awk '{
print
function foo() {
print "foo"
}
foo
}' /dev/null
I get error:
Code:
awk: syntax error at source line 4
context is
>>> function <<< foo() {
awk: illegal statement at source line 5
awk: syntax error at source line 9
Man pages state:
Functions may be defined (at the position of a pattern-action state-
ment) thus:
function foo(a, b, c) { ...; return x }
Parameters are passed by value if scalar and by reference if array
name; functions may be called recursively. Parameters are local to the
function; all other variables are global. Thus local variables may be
created by providing excess parameters in the function definition.
So where is the problem?
Code:
awk version 20110810 (FreeBSD)