Join David D. Levine for an in-depth discussion in this video Using AWK command-line flags, part of AWK Essential Training.
- View Offline
…AWK excepts a small number of flags, which will come command line our…images beginning with a dash on the command line to control it's behavior.…The f flag, specifies that the following argument is…the name of a file that contains an AWK program.…For example, the file swap, contains the same basic…AWK program we used in our very first example.…Which brings the second field followed by the first.…However, note that it is not enclosed in single quotes.…We don't need to protect is from the shell because it's already inside a file.…
We'll use the f flag to tell awk to execute this program.…On the file names.txt.…As you see, this had the same result as the command AWK print $2, $1.…You can use either the f flag or an AWK program on the…command line, in fact, you must use one or the other, but not both.…You would typically use the f flag, rather than typing the…program on the command line if the program is long or complex.…The capital F flag, AWK minus capital F, tells…AWK to use the following argument as the field separator.…
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