[Home]
HomePage RecentChanges Frequently Asked Questions

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

Edit this page View other revisions Administration
Last edited 2013年03月30日 10:38 UTC by markhobley (diff)

Powered by sdf Creative Commons License <pierre.gaston+awk@gmail.com>

Awk Wiki by #awk is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.

AltStyle によって変換されたページ (->オリジナル) /