I have a large (several GB) xml
file that is missing a root element. I might use cat
on ubuntu to wrap around a <root>
element around the content.
How can I achieve this without having to extract and repack the content?
It works if I create separate prefix and postfix gz files, and concatenate them with cat. But could I do better, without having to create explicit pre-/postfix gz files? Can I achieve the same on the fly?
echo "<root>" | gzip > prefix.gz
echo "</root>" | gzip > postfix.gz
cat prefix.gz input.xml.gz postfix.gz > newfile.gz