Join David D. Levine for an in-depth discussion in this video Creating an HTML table, part of AWK Essential Training.
- View Offline
…Now that we've discussed many of AWK's, basic features, lets start…putting them together into a program that actually does something useful.…One task for which I personally use AWK all the time, is for…converting a file of information into…a formatted table, possibly with some calculations.…Suppose you have a tab separated file of bowling scores, like this.…In this case we have the, bowlers name at the beginning and then a tab.…And then, a number of bowling scores, separated by tabs on the rest of the line.…Suppose you want to output this information as an HTML table, with a…header at the top, and an average of each numeric column at the bottom.…
Here's how to do it with AWK.…Let's create, a AWK program called scores.awk.…I'm using the VI Editor but you can use any text editor.…Let's start by producing the header.…Using the HTML tag, TH.…Because the header appears at the top of the table, we use the…special pattern begin, which matches the beginning of the input to produce it.…In this case, we know that the input file has…
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