Skip to content

Instantly share code, notes, and snippets.

@eduo
Created May 8, 2020 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduo/6d8b9da717574d1b56f39c0043d81185 to your computer and use it in GitHub Desktop.
Save eduo/6d8b9da717574d1b56f39c0043d81185 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
ls -1 *xml | while read FILE
do
FILENAME=${FILE##*/};FILEPATH=${FILE%/*};NOEXT=${FILENAME%\.*};EXT=${FILE##*.}
#echo "Testing for ${FILE} as ${NOEXT}"
xmllint --noout --schema ~/main.xsd ${NOEXT}.xml 2> ${NOEXT}.errors.txt
if grep --quiet validates ${NOEXT}.errors.txt ; then
# echo "${FILE} validates..."
rm ${NOEXT}.errors.txt
else
echo "Errors found in ${FILE}"
echo "Found $(cat ${NOEXT}.errors.txt|wc -l |bc) errors in ${NOEXT}.xml"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment