I have a source file that contains multiple XML files concatenated in it. The separator string between files is <?xml version="1.0" encoding="utf-8"?>. I wanted to split files in multiple files with mentioned names. I had used a awk code earlier to spilt files in number of lines i.e.
Not much aware of awk scripting hence dont know if we can use this code or there other better/ faster way of doing this. Below is example of source and expected target files.
I am happy with below code except two things.
1> Need a variable in awk that can be assigned so shell parameter
2> was not able to assign <?xml version="1.0" encoding="utf-8"?> to a variable
existing working code
awk '/xml version="1.0"/{x="'"${SrcFileName}_"'" sprintf("%04d",++i) ".txt";} {print > x}' $SrcFileName.txt
need a 2 line code something like
word=<?xml version="1.0" encoding="utf-8"?>
awk ' $word {x="'"${SrcFileName}_"'" sprintf("%04d",++i) ".txt";} {print > x}' $SrcFileName.txt
It will be difficult for me to justify business but even minimizing word length, Its giving same error for large source file. its running fine for small file.