GerritHiemstra
March 28th, 2012, 09:19 PM
Hello,
i was wondering if anyone has an explanation for a problem i ran into with AWK...
I will use the following simple awk script to explain myself:
BEGIN{RS=""}
END{print "num_rows: " NR}I assumed that by using an empty record separator, AWK would consider all incoming fields to be on 1 record.
Using the following example text, all seems good:
<abc>
<def>
</def>
</abc>
Output: num_rows: 1
However, using the following text (containing a situation where there's 2 or more newline characters in a row):
<abc>
<def>
</def>
</abc>
Output: num_rows: 2
How could it be?
Do i have my definitions wrong? (what precisely IS a record separator?)
Many thanks in advance!
i was wondering if anyone has an explanation for a problem i ran into with AWK...
I will use the following simple awk script to explain myself:
BEGIN{RS=""}
END{print "num_rows: " NR}I assumed that by using an empty record separator, AWK would consider all incoming fields to be on 1 record.
Using the following example text, all seems good:
<abc>
<def>
</def>
</abc>
Output: num_rows: 1
However, using the following text (containing a situation where there's 2 or more newline characters in a row):
<abc>
<def>
</def>
</abc>
Output: num_rows: 2
How could it be?
Do i have my definitions wrong? (what precisely IS a record separator?)
Many thanks in advance!