AWK Process Continued
AWK Process Continued
1
INPUT
1st routine executed before any
input is read
2nd routine(main input loop);
executed for each input line.
Can have multiple pattern-
action statements
3rd routine executed after all input is read.
2
3
Notes:
To master awk programming, its important to understand how lines of text of data are processed.
- Prior to processing any text lines, if a BEGIN pattern statement exists, it will then be executed. Remember, this statement will be executed before any data from files are processed, therefore, it only executes once! Then:
- Read a line of Input
- Compare the line of input to each pattern match specified (Remember: You can specify multiple programs or pattern action statements. Each pattern match is done sequentially as specified.
- Fore match satisfied, perform the appropriate action.
- Repeat Steps two thru four as long as there is input to process.
- Process the END pattern if one exists.
Since the pattern-actions are performed sequentially, you can process data to a specific format; where it will satisfy subsequent pattern matches.