Filename from splitting files to have the same filename of the original file with counter value
Hi all,
I have a list of xml file. I need to split the files to a different files when see the <ko> tag.
The list of filename are
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml
I have a question on how to have the same filename with the counter number append at the end on the filename?
This is the code that I used
perl -n -e '/^<ko>/ and open FH, ">output".$n++; print FH;'
and the filename I get just
output0
output1
output2
output3
output4
Actually,the filename that I needed:
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml_output0
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml_output1
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml_output2
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml_output3
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml_output4
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml_output0
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml_output1
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml_output2
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml_output3
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml_output4
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml_output0
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml_output1
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml_output2
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml_output3
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml_output4
How do modify this code "perl -n -e '/^<ko>/ and open FH, ">output".$n++; print FH;' " so that I can have the filename that I want?
Anyone have any idea?
Thanks in advance!
Last edited by natalie23; 11-12-2009 at 02:29 AM..