Join David D. Levine for an in-depth discussion in this video Building control structures, part of AWK Essential Training.
- View Offline
…So far most of the AWK programs that we've seen are very simple, performing…a basic operation like printing each line or perhaps only some lines from its input.…But AWK is a full-fledged programming language with a full complement…of control structures to control the flow of execution through a program.…AWK's Control Structures are generally similar…to those of C programming language.…The if statement executes a block of code…if, and only if, a certain condition is true.…The condition is any expression that can have a true or false value.…Conditional operators like = =, which tests…for numerical string of quality, or ~ which…tests for regular expression matching, are true…if the condition is true and false otherwise.…
A numeric value is considered false if its value is…0 and true if its value is anything other than 0.…String values are considered false if…they're the empty string and true otherwise.…The braces around the if statements are optional, if there's only…one statement, but it's very good practice to use braces every time.…
In this course, award-winning author and teacher David D. Levine shows you how to use AWK to read and write data in a variety of formats, produce reports, and automate repetitive tasks. He reviews the nuts and bolts of the language, such as field separators, pattern matching, variables, operators, expressions, and control structures; functions available for manipulating data; and integration with other programs like Excel.
- What is AWK?
- Writing an AWK program
- Working with records, fields, patterns, and actions
- Specifying field and record separators with variables
- Using built-in and user-defined variables
- Building control structures
- Formatting output
- Manipulating string data with functions
- Scripting with AWK