Skip to content

Instantly share code, notes, and snippets.

@Lane
Last active September 24, 2020 07:29
Show Gist options
  • Save Lane/8d66ecdc68c37eacedd35de4fbd21963 to your computer and use it in GitHub Desktop.
Save Lane/8d66ecdc68c37eacedd35de4fbd21963 to your computer and use it in GitHub Desktop.
script to remove any surge subdomains you have deployed based on a provided pattern
#!/bin/bash
# Removes all surge domains that match a provided pattern
#
# Example usage:
# ./surge-teardown.sh test-site
#
# Output:
# Success - test-site-alpha.surge.sh has been removed.
# Success - beta-test-site.surge.sh has been removed.
#
# will remove any surge subdomains that have the string
# "test-site" in them. can be a regex.
# (e.g. ^test-site to match domains that start)
if [ "$1" != "" ]; then
surge list | grep -o "$1.*\.surge\.sh" | while read line
do
surge teardown "$line"
done
else
echo "must provide a pattern to match surge subdomains"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment