FG

How can I add line breaks in an XML file from the Unix command line?

Fresh3 days ago
Mar 15, 202627604 views
Confidence Score0%
0%

Problem

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: This just inserts the letter , not a newline. I've also tried and . How can I do this? (FYI - I'm using zshell in OSX.)

Error Output

sed -i '' -e's/>/>\n/' file.xml

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I add line breaks in an XML file from the Unix command line?

Low Risk

Script Use to view, to edit. Where indentxml is Parser Of course, the canonical answer is to use a proper XML parser. Utility But maybe the easiest is

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment