I just checked my SSD as I was cleaning it up to get more space and I saw that snap had installed multiple version of the same software... 3 times!
I understand that snap keep the older version in case of a problem like it's explained here:
But I am not interested by that, I want to remove older versions of these apps... ALL of them and only keep the latest version.
how can I do it? any idea?
To see what I mean check out the screenshot, for example, starruler2 when I list via terminal it does not show the older version but on the file system, I can clearly see that all these snaps are taking a lot too much space.
I tried all that was written none of them worked straight out of the box but I transformed the one with a single line in the terminal, and terminal proposed me to use sudo which i have put after "then" (to remove)
and it worked just fine
For those who want it also It's below
snap list --all | while read snapname ver rev trk pub notes; do if [[ $notes = *disabled* ]]; then sudo snap remove "$snapname" --revision="$rev"; fi; done
Just a quick note for people that don't use English in their systems: you need to translate the word "disabled". I use "desactivado" in Spanish. Just run the command "snap list --all" to see how your system mark the older versions.
Another option is to add something like export LC_ALL=C to the script to force English responses.