Execute another awk from awk file

awk

Solution

Yes you can. You'll need to use the `system()` function. I'm assuming you only want to run these scripts once. If so, you can add them to the `BEGIN` block of your wrapper script:

BEGIN {
    system("awk -f ./script1.awk")
    system("awk -f ./script2.awk")
    system("awk -f ./script3.awk")
}

If you have a large number of scripts that need to be executed, you can use a `for` loop. Do make sure that your wrapper script isn't in the same directory as all the other `awk` scripts you'd like executed, or it will be included in the glob of `awk` scripts...

BEGIN {
    system("for i in *.awk; do awk -f \"$i\"; done")
}

Problem

Is it possible to execute another awk file from a awk file? Using an awk file I need to execute all awk files in a current folder. Is it possible to do such operations in awk?

Original source