Created
September 18, 2011 22:50
-
-
Save malesch/1225683 to your computer and use it in GitHub Desktop.
XML formatter (glob aware)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# == 0 ] | |
then | |
echo "Usage: xmlformat <file selector>" | |
echo "Examples: xmlformat test.xml" | |
echo " xmlformat foo*.xml" | |
fi | |
for filename in $* | |
do | |
# echo "file extension is ${filename#*.}" | |
if ([ -f ${filename} ] && [ ${filename#*.} == "xml" ]) | |
then | |
TFILE=`mktemp` | |
xmllint --format ${filename} > ${TFILE} | |
mv ${TFILE} ${filename} | |
else | |
echo "Ignoring ${filename} because not an XML file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment