Created
June 25, 2017 10:43
-
-
Save ryaan-anthony/95307264496fbf812c60ebed9ddbdf6f to your computer and use it in GitHub Desktop.
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 [ -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