| 1 |
# From [email protected] Wed Dec 15 11:32:46 2004 |
| 2 |
# Date: Tue, 14 Dec 2004 14:48:58 +0100 |
| 3 |
# From: Stepan Kasal <[email protected]> |
| 4 |
# Subject: gawk bug with RS="^..." |
| 5 |
# To: [email protected] |
| 6 |
# Message-id: <[email protected]> |
| 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 } |