Errata

sed & awk

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Other Digital Version Kindle location 521
Obtaining Example Source Code

Under the "Obtaining Example Source Code" section, the file name in the book is different than what is actually on the FTP server.

Printed: progs.tar.gz
Actual: progs.tar.Z

Thanks.

Joe Kraxner  Dec 08, 2011 
Printed Page xvii
Everywhere also on the next pages

Dear O'Reilly team,

the filename containing the sources to the book (page xvii - xix) is specified as

progs.tar.gz

in the folder /published/oreilly/nutshell/sedawk_2

However, on the server there is no such file, but the following file

progs.tar.Z

By using the commands in the book (either ftp, ftpmail, etc.), the file cannot be download, if not using the correct name progs.tar.Z

With best regards,
Marco

Anonymous  Mar 20, 2020 
Printed Page 24
the bystates program script, has a "$*." to read from standard

input,
I think this is not needed.

Anonymous   
Printed Page 24
24, 25

on page 24 the following code omits a critical line
----------------------------------------------------
#!/bin/sh
awk -F, '{
print $4 ", " $0
}' $* |
sort |
awk -F, '
$1 == LastState {
print " " $2
}
$1 != LastState {
LastState = $1
print $1
}'
--------------------------------------------------------
on page 25 the correct piece of code is shown

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

Anonymous   
Other Digital Version 48
Last paragraph first line

Errata for the errata at

http://oreilly.com/catalog/errata.csp?isbn=9781565922259

$ grep " ["[{(]*book[]})"?!.,;:'s]* " bookwords

should be

$ grep " [\"[{(]*book[]})\"?\!.,;:'s]* " bookwords

Peter J. Rosario  Sep 24, 2009 
Printed, ePub Page 83
3rd code

Code example should be:

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


The period must be escaped, i.e. \.Ah, else the regex will match any expression with any single character preceeding the Ah, e.g. ZAh, etc.

kgunders  Sep 25, 2013 
Printed, ePub Page 83
3rd code example

Ooops.. In addition to the escaped \. regexp, also need to eliminate the 3rd line, i.e.

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


Should be:

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


Else you get one too many additional blank lines in the substitution.

kgunders  Sep 25, 2013 
Other Digital Version 85
3rd example

The example, as "printed" in both ePub and Book is correct:

/^\.XX /s/substitution/substitute/

Errata is incorrect, as in:

/^.XX /s/substitution/substitute/

The period must be escaped in order to match a literal period, else otherwise will be a regex match for any single character.

kgunders  Sep 25, 2013 
PDF Page 116
Table 3.4

The Month, day, year Regex `[A-Z][a-z]\{3,9\} [0-9]\{1,2\}, [0-9]\{4\}` Will not match the month of 'May' due to the {3,9} modifier. It should read `{2,9} `

Anonymous  Oct 21, 2012 
Printed Page 133
Chapter 6

I just wanted to report a few errors in the examples from the book "sed &
awk", second edition by Dale Dougherty and Arnold Robbins.

I am referring to the examples in:

ftp://ftp.ora.com/published/oreilly/sed2/progs.tar.gz

The first error is that the name of the directory is listed in the book as:

/published/oreilly/nutshell/sedawk2/
---------------------------


Secondly, in the directory called ch06, the example entitled "phrase" is
correct in the book, but is missing a final line in the example source. The
last line should be "done". (I numbered the lines to refer to them):

01 #! /bin/sh
02 # phrase -- search for words across lines
03 # $1 = search string; remaining args = filenames
04 search=$1
05 shift
06 for file
07 do
08 sed '
09 /'"$search"'/b
10 N
11 h
12 s/.*\n//
13 /'"$search"'/b
14 g
15 s/ *\n/ /
16 /'"$search"'/{
17 g
18 b
19 }
20 g
21 D' $file
22 done <------------------------------ this is missing in the example

Finally, the "N" in line 10 should be "$!N" or the last line will always
print.

I like the book very much, and point out these items only to make it better...

HTH and Best regards,


Glenn
--------
Glenn R Williams

Anonymous  Nov 21, 2008 
ePub Page 156
Comman Substitution - nested echo w/backquotes example

ePub version reads:

echo inner1 inner2 inner1 is executed. Its output (the words inner1 inner2 inner3) is placed into the next command to be executed.

There is no "inner3". Should be "inner1", as in:

echo inner1 inner2 inner1 is executed. Its output (the words inner1 inner2 inner1) is placed into the next command to be executed.

This is printed correctly in the dead tree version, but not the ePub.

kgunders  Oct 04, 2013 
Printed Page 164
4th paragraph

In the second sentence, in the word "quotes", the 'q' and 'u' are blended together.

Lulu58e2  Oct 05, 2012 
Printed Page 168
5th paragraph (including script example)

In the word "procedure" there is a space between the 'r' and the 'e': i.e. "procedur e"

Lulu58e2  Oct 05, 2012 
Printed Page 171
1st (real) paragraph

"requires" has the 'q' blended with the 'u' and a space between "requir" and "es"

Lulu58e2  Oct 05, 2012 
Printed Page 216
"lower" program code

This code breaks on repeated capital letters. "aPPle" becomes "aaale". The "for" loop repeats twice, once for each "P". The first time gsub replaces both "P"s with "p"s. The second time "x" has advanced. CAP = "p" and index() tries to find "p" in the string "upper" which fails and returns "0" which is stored in CHAR. The substr() function in my version of awk (GNU AWK 4.0.1) treats any starting index less than 1 as 1 so gsub ends up substituting all "p"s with "a"s.

Jacques Brightly  Dec 23, 2014 
Printed Page 242
after 3rd paragraph, in man.split script

If I understand the code correctly, the first comment "#this conditional collects lines until we get to a filename" is clear and accurate for the if portion of the statement,
if (file==0)
line[++i] = $0

but it is not clear and accurate for the else portion of the statement

else
print $0 > filename
.

The else portion of the statement will print out all the lines after the line containing the previous filename until a line with a new filename is identified. The else portion also allows all the lines after the final name to be printed out. This is not clear in the comment of the code, nor is it explained in the description following the code on page 243. I think it would help the readers if the comment was modified and the action of the else statement added to the code description.

Anonymous   
Printed Page 300
3rd paragraph - output of "input.idx" script in middle of page

The contents of the "test" file is shown to include an entry:

toolkit (See X Window System).

The output of the "input.idx" script does not include the results of processing this entry. From the script, I think the entry should be processed to read:

toolkit:(See X Window System)

Anonymous   
Printed Page 401
first column

Index entry "FIELDSWIDTHS" - should read "FIELDWIDTHS"

Anonymous  Sep 08, 2011