Skip to content

Instantly share code, notes, and snippets.

@Aviksaikat
Created January 20, 2024 14:27
Show Gist options
  • Save Aviksaikat/3d75c30605d1ce8e27c354c67196d3ac to your computer and use it in GitHub Desktop.
Save Aviksaikat/3d75c30605d1ce8e27c354c67196d3ac to your computer and use it in GitHub Desktop.
remove old versions of snap packages
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
echo "Size before cleanup"
du -h /var/lib/snapd/snaps
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision;
do
snap remove "$snapname" --revision="$revision"
done
echo "Size after cleanup"
du -h /var/lib/snapd/snaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment