User-defined functions
AWK allowsusto define user-defined functions.A largecomplexcan be divided into functions where each function performs a specific task. These functionscanbe written and tested independently. This functionality means that we can reuse code.
Function definition and syntax
The definition of functions can be given anywhere between the rules of an AWK program. It is not mandatory in AWK to define a function before calling it because AWK first reads the entire program before it starts to execute it.The general syntax for defining a user-defined function is as follows:
function function_name(argument1, argument2, …local variable.) { body-of-function }
function_name
: This is the name of the function to be defined. A valid function name could consist of letters, digits, and underscores, but doesn't start with a digit and could be 52 letters in length. In a single AWK program, a variable name, array, or function should be unique.AWK keywords...