Join David D. Levine for an in-depth discussion in this video Using built-in variables, part of AWK Essential Training.
- View Offline
…Although it's simpler than other languages like Perl and Python, Awk is a…fully fledged programming language, and it has…a full complement of variables and operators.…Although this course assumes you've had some…exposure to basic programming language concepts, right now…I'm going to give you a brief introduction…to these concepts as they're implemented in Awk.…In the previous chapter, we looked at the variables FS,…RS, OFS, and ORS, which control field and record separators.…These are examples of built-in variables, which are…defined by Awk rather than by the user.…
You've also seen the variable NF, whose value is the number of fields on the line.…Related to NF is the special variable NR, whose value is the…record number or line number of the record that is currently being examined.…So instead of the number of fields, we'll print the record number.…Both of these variables can be used in patterns as well as actions.…For example, if we say, use the pattern NF is equal to six, it…prints only those lines in the input that have exactly six fields.…
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