Skip to content

Instantly share code, notes, and snippets.

@djuber
Created October 24, 2017 17:52
Show Gist options
  • Save djuber/c0ad2b76e0a7dd960d88f1331ac2312b to your computer and use it in GitHub Desktop.
Save djuber/c0ad2b76e0a7dd960d88f1331ac2312b to your computer and use it in GitHub Desktop.
xml pretty print
#!/bin/bash
if [[ "$#" = "0" ]]
then
echo "usage: $0 \$infile \$outfile"
echo "expects an xml infile, optionally write output to outfile, default is write to stdout"
else
if [[ "$#" = "1" ]]
then
cat "$1" | xmllint --format -
else
cat "$1" | xmllint --format - > "$2"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment