Greetings
When using awk to split huge xml file, I am losing an end tag on which I am filtering on. How do I go about not losing that tag or tacking it on. Interestingly the root tag is intact
Below is the awk script I am using.
Total newbee, just started awk today
Thanks
#$ cat split_bigfile.awk
BEGIN { new_chunk = 1 ; size = 100000 }
NR == 1 { header = $0 ; next }
NR == 2 { header = header ORS $0 ; footer = "</" substr($1,2) ">" ; next }
$0 !~ footer {
if (new_chunk) {
outfile = "chnk_association" sprintf("%07d", num) ".xml"
print header > outfile
new_chunk = 0
}
print > outfile
}
/<\/Association>/ {
num = int(count++/size)
if (num > prev_num) {
print footer > outfile
new_chunk = 1
}
prev_num = num
}
END { if (!new_chunk) print footer > outfile }
When using awk to split huge xml file, I am losing an end tag on which I am filtering on. How do I go about not losing that tag or tacking it on. Interestingly the root tag is intact
Below is the awk script I am using.
Total newbee, just started awk today
Thanks
#$ cat split_bigfile.awk
BEGIN { new_chunk = 1 ; size = 100000 }
NR == 1 { header = $0 ; next }
NR == 2 { header = header ORS $0 ; footer = "</" substr($1,2) ">" ; next }
$0 !~ footer {
if (new_chunk) {
outfile = "chnk_association" sprintf("%07d", num) ".xml"
print header > outfile
new_chunk = 0
}
print > outfile
}
/<\/Association>/ {
num = int(count++/size)
if (num > prev_num) {
print footer > outfile
new_chunk = 1
}
prev_num = num
}
END { if (!new_chunk) print footer > outfile }