I have a large XML file. From the Unix command line, I'd like to add a newline after every >
.
I have tried using sed for this, with no luck:
sed -i '' -e's/>/>\n/' file.xml
This just inserts the letter n
, not a newline. I've also tried \r
and \r\n
.
How can I do this?
(FYI – I'm using zshell in OSX.)
Best Answer
Script
Use
indentxml file.xml
to view,indentxml file.xml > new.xml
to edit.Where indentxml is
Parser
Of course, the canonical answer is to use a proper XML parser.
Utility
But maybe the easiest is