include

The awk extraction and reporting language does not support the use of include files. However, it is possible to provide the name of more than one source file at the command line.

_Using multiple source files_

In awk, it is possible to provide the name of more than one source file at the command line by using multiple !-f switches:

 awk -f one.awk -f two.awk

_Functions in different source files will be visible_

The functions defined in different source files will be visible from other scripts called from the same command line:

# one.awk
BEGIN {
  sayhello()
}

# two.awk
function sayhello() {
  print "Hello world"
}

_Function names must be unique across all used sources_

When more than one source file is provided at the command line, function names must be unique across all source files.

_There should not be more than one filename on the hashbang line_

It is not permissible to pass the name of additional source files through a hashbang line, because there should not be more than one parameter on the hashbang line after the interpreter name. The following hashbang line will not work:

 #!/usr/bin/awk -f two.awk