Categories
TIL

Search and parse a field with Awk

I frequently need to do extremely simple parsing. Often I resort to grep and cut, or a regular expression I send through Python or perl. Today, I learned how to use awk for this.

awk '-F: ' '/Configuration backup archive complete/{print $2}' will look for a line with “Configuration backup archive complete”, split the line up by colons, and print the second field.