Jump to content

Read big XML file with date & split into small files by Shell Script


Recommended Posts

Hello,

 

I have one big XML file (600 MB - 850 MB) in format "cells_yyyymmdd_hhmi.xml" I would like to specify that everyday i will have new file with new date. So, there should be general way to rea

 

For exmaple, i have file of 7th January. Its, cells_20140107_154016

 

Goal is to split into small parts by shell script and do operation.

 

 

Link to comment
Share on other sites

It will be great if anyone can give input to check the filesize and if it is too big, make 4 parts instead of 3 parts. :confused:
 

I did so far:

head -1125000 cells_20140107_154016.xml > PART1.xml
echo "</details></cells>" >> PART1.xml

echo "<cells><details>" >> PART2.xml
sed -n '1125001,2250000p' cells_20140107_154016.xml >> PART2.xml
echo "</details></cells>" >> PART2.xml

echo "<cells><details>" >> PART3.xml
sed -n '2250001,3480000p' cells_20140107_154016.xml >> PART4.xml

The main task is to make it in general.

Expected output:
 

head -1125000 filename.xml > PART1.xml
echo "</details></cells>" >> PART1.xml

echo "<cells><details>" >> PART2.xml
sed -n '1125001,2250000p' filename.xml >> PART2.xml
echo "</details></cells>" >> PART2.xml

echo "<cells><details>" >> PART3.xml
sed -n '2250001,3480000p' filename.xml >> PART4.xml

I hope i am clear.

Thanks in advanced for your time and input. ::)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.