|
Packit Service |
f629e6 |
# From arnold@f7.net Wed Dec 15 11:32:46 2004
|
|
Packit Service |
f629e6 |
# Date: Tue, 14 Dec 2004 14:48:58 +0100
|
|
Packit Service |
f629e6 |
# From: Stepan Kasal <kasal@ucw.cz>
|
|
Packit Service |
f629e6 |
# Subject: gawk bug with RS="^..."
|
|
Packit Service |
f629e6 |
# To: bug-gawk@gnu.org
|
|
Packit Service |
f629e6 |
# Message-id: <20041214134858.GA15490@matsrv.math.cas.cz>
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# Hello,
|
|
Packit Service |
f629e6 |
# I've noticed a problem with "^" in RS in gawk. In most cases, it seems
|
|
Packit Service |
f629e6 |
# to match only the beginning of the file. But in fact it matches the
|
|
Packit Service |
f629e6 |
# beginning of gawk's internal buffer.
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# Observe the following example:
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# $ gawk 'BEGIN{for(i=1;i<=100;i++) print "Axxxxxx"}' >file
|
|
Packit Service |
f629e6 |
# $ gawk 'BEGIN{RS="^A"} END{print NR}' file
|
|
Packit Service |
f629e6 |
# 2
|
|
Packit Service |
f629e6 |
# $ gawk 'BEGIN{RS="^Ax*\n"} END{print NR}' file
|
|
Packit Service |
f629e6 |
# 100
|
|
Packit Service |
f629e6 |
# $ head file | gawk 'BEGIN{RS="^Ax*\n"} END{print NR}'
|
|
Packit Service |
f629e6 |
# 10
|
|
Packit Service |
f629e6 |
# $
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# I think this calls for some clarification/fix. But I don't have any
|
|
Packit Service |
f629e6 |
# fixed opinion how the solution should look like.
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# Have a nice day,
|
|
Packit Service |
f629e6 |
# Stepan Kasal
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# PS: See also the discussion of the issue in the comp.lang.awk newsgroup.
|
|
Packit Service |
f629e6 |
BEGIN { RS = "^A" }
|
|
Packit Service |
f629e6 |
END { print NR }
|