I have an Oracle program producing a huge xml file which is in a concatenated form with every new type within the file having
<?xml version="1.0" encoding="UTF-8"?> as the first line in the file. A few lines after the above starter line there is another line
<index_name>US_RPI</index_name>
Now the question, what I need to be able to do is something like
-- my_awk_script.aw
OUTFILE=/tmp/my_out_file.lst
if text is /..xml.version/ --look for <?xml version this marks the begining of new type
{
if $OUTFILE exists
new_file_name=`grep index_name in $OUTFILE | get the text within > < `
mv $OUTFILE /tmp/$new_file_name
fi
-- Start the $OUTFILE afresh with new data lines
print $0 > $OUTFILE
}
else
{
-- Since this line is not a new type keep appending to the existing file
print $0 >> $OUTFILE
fi
}
I hope I was clear enough. The hash key seems to have gone bonkers on my keyboard and hence have used -- for coments.
Can I get some pointers please.
Thanks