BASH SHELL SCRIPT to split a big xml file into multiple small files BASH SHELL SCRIPT to split a big xml file into multiple small files shell shell

BASH SHELL SCRIPT to split a big xml file into multiple small files


Not pure answer but you can tune this yourself:

csplit -ksf part. src.xml /\<child\>/ "{100}" 2>/dev/null

This command will split src.xml using regexp /\<child\>/ as a delimiter and produce 1..100 part.* files.You need to play with regexp though...


One solution is to write a XSL file and use xsltproc with the stylesheet and the xml file to generate the single files.

See How to split XML file into many XML files using XSLT for an example.