Errata

Last updated Mon Jun 2 16:25:28 EDT 2025

These are listed in page number order.

  • Sep 20, 2023, page 3, line -5:

    The input line Kathy 15.50 10 should be in italic. Thanks to Galen Menzel for spotting this error.

  • Oct 6, 2023, page 9, line -2:

    It should say "$2 is less than 20 ..." to match the code. Thanks to Kevin Lo for spotting this error.

  • Oct 10, 2023, page 24:

    The test at the top of the page should be

    NR == 10 { exit }
    
    Otherwise the code prints 11 lines, not 10. Thanks to Mark Konezny.

  • Sep 16, 2023, pages 26 and 27:

    The streaming version of mc one page 26 prints output in 7 columns, not 5, since the loop starts with n set to zero and ends with n = 6. Here's a better version:

    { out = sprintf("%s%-10.10s  ", out, $0)
      if (++n >= 5) {
        print substr(out, 1, length(out)-2)
        out = ""
        n = 0
      }
    }
    

    The second version of mc on page 27 has a different problem: it doesn't include the two spaces between columns when computing the number of columns, so the result is always too high. Probably easiest fixed like this:

      ncol = int(60 / (max+2) + 0.5)  # int(x) returns integer value of x
    
    Many thanks to 郭济琳 (Jilin Guo) for spotting these errors.

  • Oct 8, 2023, page 32, line 9:

    The expression s = s $n++ " " in the function rest works on Awk but not on Gawk. It's an ambiguity in resolving the precedences of the prefix $ and the postfix ++. Fixed by adding parentheses:

    s = s $(n++) " "
    
    The same construction appears near the middle of the page and is fixed in the same way. Thanks to 郭济琳 (Jilin Guo).

  • Oct 8, 2023, page 33, line -10:

    The split function is better written as

    split(date, d)
    
    to properly handle single-digit days that might be preceded by two spaces instead of one. Alternatively, the third argument could be /  +/. Thanks to 郭济琳 (Jilin Guo).

  • Nov 4, 2023, page 42, line -10:

    The test should be $5 < 0.5 to match the text, which says "What about beer with less that say 0.5%?" Thanks to 郭济琳 (Jilin Guo).

  • Nov 21, 2023, page 88:

    The derivation at the bottom of the page is missing a couple of intermediate states. It should read

    Sentence -> Nounphrase Verbphrase
             -> the girl Verbphrase
             -> the girl Verb Modlist Adverb
             -> the girl runs Modlist Adverb
             -> the girl runs very Modlist Adverb
             -> the girl runs very very Modlist Adverb
             -> the girl runs very very Adverb
             -> the girl runs very very quickly
    
    Thanks to Eran Yarkon.

  • Nov 21, 2023, page 94, line -10:

    In

    pfx = tolower($0)
    gsub(/[^A-Za-z]/, "", pfx)
    
    the RE doesn't need A-Z since pfx has no upper case letters. Thanks to Eran Yarkon.

  • Nov 27, 2023, page 111, line 8 of section 7.2:

    The display should read title caption, not label.

    On page 114, the line { ok = 1 } about 12 lines up from the bottom of the page doesn't do anything since ok is set to zero by the next pattern.

    On page 115, inside the for loop in the END block, there's no need to test flag again; it's never empty at this point. Thanks to Eran Yarkon for these.

  • Jun 16, 2024, page 164:

    The sentence describing the countries file would be clearer if the descriptions were in the same order as the columns, as in "Each line contains the name of the name of a country, its area in thousands of square kilometers, its population in millions, and the continent it is in."

    Thanks to Eric Bowles.

  • Jun 2, 2025, page 205:

    The line

     close(x) 
    in the include program should be
     close($2) 
    Thanks to Will Clardy.