Line | |
---|
1 | # From arnold@f7.net Wed Dec 15 11:32:46 2004
|
---|
2 | # Date: Tue, 14 Dec 2004 14:48:58 +0100
|
---|
3 | # From: Stepan Kasal <kasal@ucw.cz>
|
---|
4 | # Subject: gawk bug with RS="^..."
|
---|
5 | # To: bug-gawk@gnu.org
|
---|
6 | # Message-id: <20041214134858.GA15490@matsrv.math.cas.cz>
|
---|
7 | #
|
---|
8 | # Hello,
|
---|
9 | # I've noticed a problem with "^" in RS in gawk. In most cases, it seems
|
---|
10 | # to match only the beginning of the file. But in fact it matches the
|
---|
11 | # beginning of gawk's internal buffer.
|
---|
12 | #
|
---|
13 | # Observe the following example:
|
---|
14 | #
|
---|
15 | # $ gawk 'BEGIN{for(i=1;i<=100;i++) print "Axxxxxx"}' >file
|
---|
16 | # $ gawk 'BEGIN{RS="^A"} END{print NR}' file
|
---|
17 | # 2
|
---|
18 | # $ gawk 'BEGIN{RS="^Ax*\n"} END{print NR}' file
|
---|
19 | # 100
|
---|
20 | # $ head file | gawk 'BEGIN{RS="^Ax*\n"} END{print NR}'
|
---|
21 | # 10
|
---|
22 | # $
|
---|
23 | #
|
---|
24 | # I think this calls for some clarification/fix. But I don't have any
|
---|
25 | # fixed opinion how the solution should look like.
|
---|
26 | #
|
---|
27 | # Have a nice day,
|
---|
28 | # Stepan Kasal
|
---|
29 | #
|
---|
30 | # PS: See also the discussion of the issue in the comp.lang.awk newsgroup.
|
---|
31 | BEGIN { RS = "^A" }
|
---|
32 | END { print NR }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.