Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
set -e
export IFS='
'
# that's a dangerous script to run because it removes all your snaps. Don't do that
function echo_cmd() {
echo "$@"
#$@
}
snaps=`mktemp -p /tmp remove-snaps.XXXXXX.txt`
echo ":: Listing mounts ..."
for f in $(df | awk "{ print \$6 }" | grep snap | sort)
do
echo "$f"|tee -a $snaps
done
echo ":: Unmounting ..."
for item in `cat $snaps`
do
echo_cmd "sudo umount $item"
done
echo ":: Removing folders ..."
for item in `cat $snaps`
do
echo_cmd "sudo rmdir $item"
done
echo ":: Removing files ..."
for item in `cat $snaps`
do
snap=`echo $item | sed 's/\/snap\///g' | sed 's/\//_/g'`
echo_cmd "sudo rm /var/lib/snapd/snaps/$snap.snap"
done
rm $snaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.