I have a file that contains about 5GB worth of text. I would like to break this up into multiple smaller files based on each time a specific string comes up.
What I am trying to do is put together a script or even a one liner that reads through the file looking for <ticket>
and </ticket>
and each time it finds those it copies those two lines plus the content in between to a new file. Each time it finds a match for those strings I need it to create a new file though.
What thought would do this for me is something like:
#!/bin/bash
i=0
for f in BF_File.xml; do
let i++;
sed 's#.*<ticket>\(.*\)</ticket>#\1#' "$f" > Smaller_File_"${i}".xml
done
but this just ends up copying the contents of the original file into a Smaller_File_1.xml
Any help would be greatly appreciated!