O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making indirect function calls

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required