Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
Created June 25, 2017 10:43
Show Gist options
  • Save ryaan-anthony/95307264496fbf812c60ebed9ddbdf6f to your computer and use it in GitHub Desktop.
Save ryaan-anthony/95307264496fbf812c60ebed9ddbdf6f to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z $1 ]
then
echo 'Sitemap must be provided as first argument.';exit 2
fi
# Helper function to read xml
read_dom () {
local IFS=\>
read -d \< ENTITY CONTENT
}
mkdir tmp
cd tmp
wget $1
cd ../
while read_dom; do
if [[ $ENTITY = "loc" ]]; then
echo $CONTENT
fi
done < tmp/sitemap.xml > sitemap.txt
rm -rf tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment