Day 34: Never too Good to Review awk

I tried to play with awk again to finish the last exercise in Lecture 4 of the the MIT missing semester course. I pulled the HTML table data using pup but manipulating it with awk had me re-reading my notes. After re-reading my notes I realized they were pretty trash and I need to review what I learned and try this all again LOL.

TLDR;

Okay, so here are the highlights of what I did:

  • I read through the docs for the pup command-line program for processing HTML. It is a little weird to use since you are running CSS selectors in the command line while trying to pull data and not style any of it. It’s kind of trippy lol.
  • I re-read the lecture notes from the MIT Missing Semester Lecture. I tried to work on the last exercise but my awk skills were pretty crummy so I couldn’t figure it out. I don’t want to cheat and google the solution. I want to use this opportunity to revisit awk and improve my familiarity with it as a language and command-line tool.
  • I finished going through chapter 3 in the “Programming from the Ground Up” book by Jonathan Bartlett. It covered more details on registers which I only slightly understood. LOL

Notes from gawk manual – Expressions


GAWK Expressions (Section 6)

Expressions are the basic building blocks of awk patterns and actions. An expression evaluates to a value that you can:

  • print
  • test
  • pass to a function

Additionally, an expression can assign a new value to a variable or a field by using an assignment operator.

An expression can serve as a pattern or action statement on its own. Most other kinds of statements contain one or more expressions that specify the data on which to operate. As in other languages, expressions in awk can include variables, array references, constants, and function calls, as well as combinations of these with various operators.

How Expressions Work

Expressions are built up from the values and constants that are comprised of:

  • values (Constants, variables, conversions)
  • operations that are performed on the values

References


Conclusion

That’s all for today. If you are interested in the MIT course you can check out the video lecture I’m currently going through. The lecture is helpful but isn’t sufficient by itself. Anyways, until next time PEACE!