sed & awk

Errata for sed & awk

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page xxii
changed both instances of "ora.com" to "oreilly.com"

Anonymous    Sep 01, 1997
Printed
Page xii and xxii
in the last printing, the printer inserted the page we

had sent to replace xxii as xii instead. So I sent them new ones to fix the mistake.

Anonymous    Oct 01, 1997
Printed
Page xvii and xviii
changed all the instances of "ora.com" to "oreilly.com"

Anonymous    Oct 01, 1997
Printed
Page xxii
The following information was added to the "Comments and Questions"

section of the preface: "We have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). Please let us know about any errors you find, as well as your suggestions for future editions, by writing to: ... "We have a web site for the book, where we'll list examples, errata, and any plans for future editions. You can access this page at: http://www.oreilly.com/catalog/9781565922259/ For more information about this book and others, see the O'Reilly web site: http://www.oreilly.com"

Anonymous    Jan 01, 2000
Printed
Page 7
added the following footnote, anchored at "the exclamation point

alone.": Well, you can set the histchars variable. See the csh man page.

Anonymous    May 01, 1998
Printed
Page 21
para. -3: changed "and the city" to "or the city"

Anonymous    May 01, 1998
Printed
Page 24
1st code example: removed 5th line from the bottom ("print " " $2")

Anonymous    Sep 01, 1997
Printed
Page 24
1st code changed:

}' $* | sort | awk -F, ' $1 == LastState { print "  " $2 } $1 != LastState { LastState = $1 print $1 }'

Anonymous    May 01, 1998
Printed
Page 24
code sample 1, replaced last four lines

$1 != LastState { LastState = $1 print $1 }' with $1 != LastState { LastState = $1 print $1 print " " $2 }'

Anonymous    Aug 01, 1998
Printed
Page 25
2nd code example changed to

$1 == LastState { print "  " $2 } $1 != LastState { LastState = $1 print $1 print "  " $2 }'

Anonymous    May 01, 1998
Printed
Page 29
Figure 3-1, section 3: the two letter a's in "jar" and "abe"

are now in bold, as they are in section 6.

Anonymous    Aug 01, 1998
Printed
Page 38
1st bullet item: fixed broken cross-reference; it now says "see

Table 3-3"

Anonymous    Apr 01, 1998
Printed
Page 39
in table, changed "Alphanumeric characters" to "Printable

characters (includes whitespace)"

Anonymous    May 01, 1998
Printed
Page 39
Table 3-3, row 8, column 2: changed "Alphanumeric characters"

to "Printable characters (includes whitespace)"

Anonymous    Aug 01, 1998
Printed
Page 39
table

In the table for character classes, [:alnum:] should match "Alphanumeric Characters", not "Printable characters (includes whitespace)".

Anonymous    Aug 01, 2008
Printed
Page 47
para. 2: added "for grep" after "a regular expression"

Anonymous    May 01, 1998
Printed
Page 48
Last paragraph first line

Should read: $ grep " ["[{(]*book[]})"?!.,;:'s]* " bookwords (This change escapes the exclamation point. It's needed only if you use bash or csh as your shell. At the time I wrote it, I was using ksh which doesn't have the problem.)

Anonymous    Aug 01, 2008
Printed
Page 51
In the script code for the gres command, the following has been

inserted as the first line: #!/bin/sh Also, the superfluous double quotes around "3" in the first line of the script have been removed. Also, as it's common practice to output usage & error messages to stderr. The first two echo commands have been appended with >&2 as follows: echo Usage: gres pattern replacement file >&2 and: echo $3 is not a file. >&2

Anonymous    Jan 01, 2001
Printed
Page 53

The gres command in the middle of the page used to read: .Se 00 "Appendix" It now reads: .Se 00 "Full Program Listings"

Anonymous    Apr 01, 2000
Printed
Page 54
table: Month, Day, Year entry: added "" before the "}" after "2"

Anonymous    May 01, 1998
Printed
Page 57
The two instances of sample script have been updated to use

global subsitution. The first one, for example, now reads: s/pig/cow/g s/cow/horse/g The second one now reads: s/cow/horse/g s/pig/cow/g

Anonymous    May 01, 1999
Printed
Page 58
Figure 4-1 shows a script. The first line of the script

now ends with a slash "/"

Anonymous    Apr 01, 2000
Printed
Page 73
last code example, line 2: put "Chapter" in all caps

Anonymous    May 01, 1998
Printed
Page 74
next-to-last code, line 3: put "Chapter" in all caps

Anonymous    May 01, 1998
Printed
Page 74
para. -3: changed "TeX" to "LaTeX"

Anonymous    May 01, 1998
Printed
Page 81
line 2: deleted "a blank or"

Anonymous    May 01, 1998
Printed
Page 83
para. 3: changed "a blank line" to "blank lines"

Anonymous    May 01, 1998
Printed
Page 83
3rd code changed to

/^.Ah/{ s/.Ah */ @A HEAD = / s/"//g s/$/ / }

Anonymous    May 01, 1998
Printed
Page 85
code example -3 changed to

/^.XX /s/sed, substitution command/sed, substitute command/ code example -2 also changed: /^.XX /s/substitution/substitute/

Anonymous    May 01, 1998
Printed
Page 88

changed footnote to read: The original UNIX documentation says that any leading tabs or spaces in the supplied text will disappear on output. This is the case on older versions, such as SunOS 4.1.x and /usr/ucb/sed on Solaris. System V and GNU sed do not delete the leading whitespace. If they disappear on your system, the solution is to put a backslash at the beginning of the line, preceding the first tab or space. The backslash is not output.

Anonymous    May 01, 1998
Printed
Page 101
2nd code example changed

.Rh 0 "DBclose" "closes a database"

Anonymous    May 01, 1998
Printed
Page 105
code examples 1 and 2 changed to (respectively)

sed -n " /^.de *$mac/,/^..$/{ p /^..$/q }" $file and: /^..$/q

Anonymous    May 01, 1998
Printed
Page 105
para. 1, line 3: changed "Writing sed Scripts," to "Writing

sed Scripts)" (changed comma to close parenthesis.)

Anonymous    Aug 01, 1998
Printed
Page 115
In line 3 of the script in Figure 6-1

The "s" command is now lower case.

Anonymous    Sep 01, 2000
Printed
Page 133
IN PRINT: Code sample at bottom of page, lines 10 and 15

SHOULD BE: "$!N"

Anonymous    Aug 01, 2008
Printed
Page 153
code sample 5: added a blank line between 2 and 3 lines so

that the sample now reads as follows: John Robinson, 696-0987 Phyllis Chapman, 879-0900 2 records processed.

Anonymous    Aug 01, 1998
Printed
Page 155
The check book balancer has been fixed to now allow deposits.

The last two lines on the page now read: 125 Market -125.45 126 Hardware Store -34.95

Anonymous    May 01, 1999
Printed
Page 156
The same changes as page 155 with putting a negative sign before

the amount spent on each item. Also, in the middle of the page, the last 5 lines of code now read: #2 Apply to each check record, adding amount from balance. { print $1, $2, $3 print balance += $3 # checks have negative amounts }

Anonymous    May 01, 1999
Printed
Page 157
The following text was added to the top of the page

you'd want to make to this program to improve it, and refining a program takes much longer. The point is that with awk, you are able to isolate and implement the basic functionality quite easily. </para>

Anonymous    Apr 01, 2000
Printed
Page 163
In the last line

for a directories has been changed to: for directories

Anonymous    Jan 01, 2001
Printed
Page 165
In the table, in between the entries for 's' and 'x',

the following entry has been added: u Unsigned decimal value

Anonymous    Jun 01, 2001
Printed
Page 171
para. 2: added a footnote to the end of the line

"Here's the info script using awk:". The footnote text is Remember that you need an awk that provides POSIX semantics for this to work. It may be named awk, nawk, or even something else! Check you local system documentation. ("awk" and "nawk" are in bold.)

Anonymous    Aug 01, 1998
Printed
Page 191
2nd code block, line 5: changed "numberals" to "numerals"

Anonymous    Apr 01, 1998
Printed
Page 195
code sample 1: changed lines 5 through 7 from

if ( $i in acro ) { # if it matches, add description $i + acro[$i] " (" $i ")" to if ( $i in acro ) { acronym =$i # if it matches, add description $i = acro[$i] " (" $i ")"

Anonymous    Aug 01, 1998
Printed
Page 212
para. 6, line -2: changed "Use "&"" to "Use "&""

Anonymous    May 01, 1998
Printed
Page 221

The second code block, fourth line read: for (j - i; ARRAY[j-1] > ARRAY[j]; --j) { but now reads: for (j = i; (j-1) in ARRAY &amp;&amp; ARRAY[j-1] &gt;

Anonymous    Jan 01, 1999
Printed
Page 221
The fourth paragraph, third line ending with

"elements are swapped." A footnote was added: "We have to test that j-1 in ARRAY, first, to make sure we don't fall off the front end of the array." Note: "j-1" and "ARRAY" are bold.

Anonymous    Jan 01, 1999
Printed
Page 236
code sample 4, added dash at the end of the line. The line

now reads awk -v CMDFILE="uucp_commands" script - ("script" is still constant-width italic font.)

Anonymous    Aug 01, 1998
Printed
Page 246
last code on page: changed "orders.today" to "orders"

Anonymous    May 01, 1998
Printed
Page 248
Last paragraph first first sentence

If a program has a number of branching constructs, you might find that an input line falls through one of branches. Should read: If a program has a number of branching constructs, you might find that an input line falls through one of the branches.

Anonymous    Aug 01, 2008
Printed
Page 256
code sample 3, line 2: "#! /bin/sh" should be "#!/bin/sh"

(closed-up the space)

Anonymous    Dec 01, 1998
Printed
Page 263

The ftp location for GNU awk has been updated. It now reads: ftp.gnu.org and /gnu/gawk/gawk-3.0.3.tar.gz

Anonymous    May 01, 1999
Printed
Page 263

Under "GNU awk (gawk)," second paragraph, line 2 read: /gnu/gawk/gawk-3.0.3.tar.gz It now reads: /gnu/gawk/gawk-3.0.4.tar.gz

Anonymous    Sep 01, 1999
Printed
Page 272
Code in 1st and 3rd paragrah

the contents should show: $ cat querylog mary:another.domain.org:831312546 arnold:some.domain.com:831322007 arnold:some.domain.com:831324598 arnold:some.domain.com:831327215 mary:another.domain.org:831346231 and then in the next example, when the program is run, the results should be: $ gawk -f cgiformat.awk /var/log/cgi/querylog mary@another.domain.org -> 2 times between 96-05-05 12:09 and 96-05-05 21:30 arnold@some.domain.com -> 3 times between 96-05-05 14:46 and 96-05-05 16:13

Anonymous    Aug 01, 2008
Printed
Page 274

code sample, changed alignment so that it now reads: a[1][1] = "hello" a[1][2] = "world" for (i in a [1]) print a[1][i]

Anonymous    Aug 01, 1998
Printed
Page 409
added the following to the end of the next-to-last para.

Whenever possible, our books use RepKover (tm), a durable and flexible lay-flat binding. If the page count exceeds RepKover's limit, perfect binding is used.

Anonymous    Sep 01, 1997