View source
# 2024-06-26 - AWK Recipe

I manage a collection of about 80,000 or so recipes.  Most of them
are in a plain-text format used by the Meal-Master recipe manager.
The top line is supposed to be something like:

    MMMMM----- Recipe via Meal-Master (tm) v8.06

The other day i found one that had a few unwanted lines on top.  It
was probably a "copy paste" error from years ago.  I hand fixed the
recipe format, but wanted to search my collection to see whether any
other recipes needed to be fixed.

I wrote a quick awk script to report whether a file has lines before
the Meal-Master signature, then i ran it on the whole database.  To
my surprise, it took less than 10 seconds to search all 80k recipes.

    $ find moar/ascii -type f | xargs awk '
    /via [Mm]eal-[Mm]aster/   { if (FNR > 1) found[FILENAME] = 1 }
    END                       { for (fn in found) print fn }' >rlis

It found a total of 35 other recipes that needed to be fixed.

What's my point?  I got a kick out of how quickly i arrived at a
solution using awk.  It was easy and effective.

By the way, i tried it using gawk, mawk, and nawk, and got the
same results in all three.

tags: bencollver,retrocomputing,technical

# Tags
bencollver
retrocomputing
technical