Removing unused snap packages

I think that Ubuntu 22.04 doesn’t remove old snap packages when they become unused because on my system this command:

snap list --all

shows a long, long list of packages.

User chipaca found an elegant solution [sh]:

LANG=C snap list --all | while read snapname ver rev trk pub notes; do if [[ $notes = disabled ]]; then sudo snap remove "$snapname" --revision="$rev"; fi; done

Resources

[sh] How to remove disabled (unused) snap packages with a single line of command?
https://askubuntu.com/questions/1036633/how-to-remove-disabled-unused-snap-packages-with-a-single-line-of-command

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.