Re: [xml] Can xmllint format with in-place file saving?

On Sun, 2010-08-01 at 10:37 -0400, mruhrbach aim com wrote:
Hello list,

I run xmllint to format my XML file: xmllint --format file.xml

The output goes to stdout, so I capture it in a file: xmllint --format 
file.xml > formatted.xml

Now I replace the old with the new: mv formatted.xml file.xml

Question: can this be done in one step? I imagine something like: 
xmllint --format --in-place file.xml, as is known form sed.

Maybe like this little script.

Beware that if there is an error in your file,
xmllint will not produce any output, and you risk losing the


#! /bin/sh

for i
    mv "$i" "$i.bak" || exit 1
    xmllint --format "$i.bak" > "$i"

Liam Quin - XML Activity Lead, W3C,
Pictures from old books:

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]