Skip to content

Instantly share code, notes, and snippets.

@dpodyachev
Forked from m-esm/remove-old-snaps.sh
Created June 26, 2025 09:16
Show Gist options
  • Select an option

  • Save dpodyachev/32ebf163a573e6bd9e995a94224be38d to your computer and use it in GitHub Desktop.

Select an option

Save dpodyachev/32ebf163a573e6bd9e995a94224be38d to your computer and use it in GitHub Desktop.
Removes older versions of Snap applications
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
echo "Current usage:";
du -h /var/lib/snapd/snaps
echo "";
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
echo "Usage after removing old versions:"
du -h /var/lib/snapd/snaps
@dpodyachev
Copy link
Copy Markdown
Author

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment