[Last updated Nov 11, 1996] The following is a list of errata I've compiled for the Sed & Awk book by Dale Dougherty. [Note that this is for the first edition only (i.e. the one that came with a separate errata sheet). Later printings of the first edition have many of these errors corrected.] Not all of the "errors" are necessarily logical or typographic; some deal with style and/or conceptual differences between myself and the author. I hope that this list is taken as constructive criticism meant to improve the next edition of the book. This list is by no means complete and doesn't claim to be. The format for this file is *usually* where the error occurred what the error was what the corrected text should be In some instances, the error itself is mentioned in the corrected text. My thanks goes out to Arnold D. Robbins for improving this list and for his work on the soon-to-be-released second edition of the Sed & Awk book. page xvii Versions of awk and sed for DOS can be found at: http://cccsat.sorostm.ro/pub/simtelnet/gnu/gnuish Look for gawk300x.zip and sed106.zip page 4, fifth paragraph "Sed also has the unique ability to be used as an editing filter" Actually, many unix tools can be used as "editing filters," not just sed. page 9, after fifth paragraph % ed test 339 One inconsistency of the book is that example files are employed without first knowing what is in the files. I would suggest that before using any file, please present the entire contents of the file to the reader. page 16, first example; page 17, first example Another inconsistency is the Author's constant flipping between Bourne shell variants (sh, ksh, bash) and csh shell variants (csh, tcsh). Most modern operating systems are shipped with some flavor of both variants, so I would suggest picking one shell and sticking with it. page 17, under 3. "Use the multi-line entry capability of the Bourne shell." Any Bourne shell variant possesses this capability (ksh, bash). page 18, first example. "sed: command garbled: ..." The gnu variant of sed provides more information. In this case, "Unterminated `s' command" is its reply. Since the author mentions gawk and its capabilities quite frequently throughout the book, it would also be instructive to mention gnu sed as well. page 23, above "Summary of Options" "Nawk tends to be more helpful than awk ..." So is gawk. page 25, first full example nameState list | byState sed -f nameState list | byState page 31, \{n,m\} special character Because {} is special to most shells, such a construct used on the command line must be *at least* weak quoted. [more on this later] page 33, 80.86 example This is a poor choice because the 8086 processor is part of the Intel family of microprocessors, but 80.86 will not match 8086. page 34, 3rd paragraph WEEKLY.SALARY is a poor name for a variable just after a long discussion of what . means. How about WEEKLY-SALARY? page 38, 4th paragraph [0-9a-z?,.;:'"] as a multiple range example. If such a class were used on the command line, it would inevitably fail. This is a persistent problem in the text, i.e. the problem of quoting. In many shells, both ' and " are used as quoting characters. The trick is that while one may be used to quote the other (I can get a ' by doing "'" or a " by doing '"'), I cannot print out both with the same command. Several of the examples, especially the one on page 50, will never work because it requires both " and ' as literals, not as quote characters. I would suggest presenting a discussion of the intricacies of quoting in whatever shell is chosen (see above) and removing all non-working examples from the text. page 38, bottom The regular expression presented also matches non-existent dates like 00-39-00 and 19-39-00. page 47, 5th paragraph % egrep "Lab(oratorie)?s mail.list % egrep "Lab(oratorie)?s" mail.list page 48, grep example "such as booky" does not appear in the output unless one adds a space after the y. page 49, grep example Example does not work because of shell quoting. page 50, grep example Example does not work because of shell quoting. page 54, paragraph 11 "a single digit followed by at least five dots ..." "a single digit followed by zero or more digits followed by at least five dots ..." page 54, sed example ` in example should be a ' page 60, 5th paragraph s/CA/California/ should read s/CA/California/g to have it change all instances on a single line page 62, ! example If used on the command line, the ! will have to be quoted in some way (csh anyway). page 63,65, use of diff On page 63, diff is used for comparison. On page 65 in the runsed script, cmp is used for comparison. page 69, s/ example s/. */. /g s/\. */. /g page 69-70, file name inconsistency Example file name changes from "horsefeathers" to "basic" to "hp.product.bulletin." page 72, sed script "A troff macro definition always begins with the string ".de," followed by an optional space ..." The sed script presented does not account for the optional space. page 74, do.outline example Sample working file is not presented. page 75, "basic script" The spaces in the third and fourth lines after the second forward slash are tabs. This is not noted anywhere. page 76,77, all s and ! commands Quoting problems again. page 77, 5th paragraph (troff (In troff. page 84, 1st example under "Replacement Metacharacters" s/ /\ /2 Csh based shells eat the newline. I found no problem with sh based shells. page 86, sed example % sed "s/... test1 % sed "s/..." (missing right ") page 93, output of second example \15 \07 In gnu sed, the output of \15 \07 is \r \g. page 97, second example % sed -f sed.debug ch05 The text of ch05 is not presented. page 99, example after "The following script ..." /^.H1/{ /^\.H1/{ page 105, 3rd text paragraph "The we substitute ..." "Then we substitute ...." page 105, last example 1/ \1/ page 106, example 2./ \2./ page 108, sed -n example Shell script ends in "done." Obviously, this is a fragment of the previous getmac script. It would be clearer to reprint the entire script and not just the changed lines. page 121, sed example The last line of the "test" file "Another @f1(one)" does not appear in any form after the execution of sed.len. page 131, pattern space ... for editing.<> ... for editing.

page 131, last sentence Sentence beginning with "Then we use the ..." is printed twice. page 135, both examples /.Rh 0/ /\.Rh 0/ page 138, phrase script The third line should be a commented line, as this sh script will not run as written. page 142, first awk program "... test that contains a single blank line." For simplicity, "a one line file." page 143, output of first example The output is in a bolded font. page 145, several problems At the top of the page, the example uses the phrase "This is a blank line." In the middle awk code, it has been replaced by "This is a blank." The print statements for "string" and "blank" are missing periods at the end. I believe the author meant /[A-z]+$/ for the /[A-z]+/ line. If not, the output for the 4T example below the code is incorrect. page 146, single quote in a comment Using a single quote in a comment has no adverse effects under gawk 2.15.5. I don't believe that if the -f option is used that shell quoting will have any effect on the script. Doesn't {g,n}*awk read the file by its own internal mechanisms? page 146, blank awk script "This is a blank line" is once again missing a period. page 147, second awk example % awk -F\t ... The \t doesn't work under csh based shell and gawk 2.15.5. Using a Tab works, as does -F\\t. page 149, 4th awk example $6 ~ /1?(-| )* ... $6 ~ /1?(-| )? ... page 156, phonelist.awk print NR "records printed." } print NR " records printed."} to get output presented below example. page 163, second example ... $9 } ... $9 (no }) page 164, BEGIN example BEGIN { print "BYTES" "" "FILE" BEGIN { print "BYTES" "\t" "FILE" page 165, under #4 in example $1 ~ /^..*:$/ $1 ~ /^\..*:$/ page 185, factorial example 0! = 1. This is not accounted for in the program. page 191, "order example" gawk 2.15.5 does not order according to entry; neither does nawk on the systems I tested when the number of array entries increases. page 192, example BEGIN { OFS = "" } BEGIN { OFS = "\t" } page 196, fullname example ... and the last person's name can be referenced as: fullname[z] ... and the last person's name can be referenced as: fullname[sizeOfArray] page 197, example $1 > 0 && $1 < 10 { $1 > 0 && $1 <= 10 { page 204, top of page printf("0) printf("\n") page 216, Awk's Built-In String Functions The index() function is incorrect. index(s,t) returns the index of the string t in the string s, or 0 if t is not present. page 219, Making an assignment to a field This technique is first used on page 201,202 without explanation. page 221, timex command timex is a system V-ish command. It does not exist on straight BSD derived systems, such as Ultrix. page 224, example The index command is incorrect. It is used as presented in the book (which is incorrect). page 232, example /.SH "Related ... /\.SH "Related ... page 233, example Both printf statements are missing a closing " page 239, nawk example Any example that users /etc/passwd is probably obsolete. Most systems do not contain users passwd entries in /etc/passwd, but rather in a yp (nis) database or in an unreadable /etc/security/passwd. In any case the example should probably be replaced. page 245, clear comment On all Unix systems I tested, clear is the command to clear the screen. cls is the Dos command to clear the screen. page 253, last sentence above Generating Columnar Reports man* What does the * refer to? Missing footnote, perhaps? No, it actually refers to the regular expression man*. Using * for footnotes, in hindsight, was probably a bad idea. page 258, notion of core dump From my perspective (i.e. IMHO), scripts themselves cannot core dump, since when a script dies it does not leave a core file. The awk executable or the shell itself, however, could core dump, but I don't think that that was what the author meant. --- Zube zube@stat.colostate.edu