Data between <wmqi></wmqi> is a record.
here there are 5 records. I need to do a split on 2 records(i.e create 3 files).
I learnt about csplit but unable to implement it.
Can anyone help.
---------- Post updated at 01:04 PM ---------- Previous update was at 12:07 PM ----------
Hello you can use perl. works great with xml files.
xml::parser module ought to be enough.
you can search cpan.org for appropriate xml modules.
Regards.
rec=0
seq=0
while read -r line
do
case $line in
"</wmqi>" )
if [ $rec -eq 2 ]
then
rec=0
seq=$((seq+1))
fi ;;
"<wmqi>" )
rec=$((rec+1)) ;;
*) printf "$line\n" >> file$seq.out ;;
esac
done < infile