March 2018
Beginner to intermediate
416 pages
9h 24m
English
Using indirect function calls, we can specify the name of the function to be called as a string to a variable and then call the function with the new variable. In indirect function calls, we tell GAWK to use the value of the variable as the name of the function to be called. The indirect function is called by prefixing the @ character with the variable name that has been assigned the function as a string. The following example shows how indirect function calls work:
$ vi func4.awkfunction demo(){ abc = "Welcome to awk" return abc}BEGIN { myfunc = "demo" print @myfunc()}$ awk -f func4.awk
The output of the execution of the previous code is as follows:
Welcome to awk
In the previous example, we assign the demo() ...
Read now
Unlock full access