Skip to content

Instantly share code, notes, and snippets.

@laradevitt
Last active January 7, 2021 18:20
Show Gist options
  • Save laradevitt/fa3204d63c1b043f379f25e5f611b1fb to your computer and use it in GitHub Desktop.
Save laradevitt/fa3204d63c1b043f379f25e5f611b1fb to your computer and use it in GitHub Desktop.
Randomly selected sample - get a specified number of random entries from a website XML sitemap. Usage: ./random-from-sitemap.sh http://domain.com/sitemap.xml 10
#!/bin/sh
SITEMAP=$1
COUNT=$2
if [ "$SITEMAP" = "" ] || [ "$COUNT" = "" ]; then
echo "Usage: $0 https://example.com/sitemap.xml 1"
exit 1
fi
curl $SITEMAP | grep -e loc | shuf -n $COUNT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment