Monday, May 20, 2024
53
rated 0 times [  53] [ 0]  / answers: 1 / hits: 56205  / 3 Years ago, fri, may 7, 2021, 1:05:28

When I run snap list --all command it shows all the installed versions of snap packages.



Name                  Version       Rev   Tracking  Developer     Notes
atom 1.26.1 150 stable snapcrafters classic
brave v0.22.669dev 23 stable brave -
core 16-2.32.6 4571 stable canonical core
core 16-2.32.5 4486 stable canonical core,disabled
firefox 59.0.2-1 71 stable mozilla disabled
firefox 60.0-2 85 stable mozilla -
gimp 2.10.0 38 stable snapcrafters disabled
gimp 2.10.0 39 stable snapcrafters -
gimp 2.8.22 30 stable snapcrafters disabled
gnome-3-26-1604 3.26.0 64 stable/… canonical -
gnome-3-26-1604 3.26.0 62 stable/… canonical disabled
gnome-characters 3.28.0 86 stable/… canonical -
gnome-characters 3.26.2 69 stable/… canonical disabled
gnome-logs 3.26.2 25 stable/… canonical disabled
gnome-logs 3.28.0 31 stable/… canonical -
gnome-system-monitor 3.26.0 36 stable/… canonical disabled
gnome-system-monitor 3.26.0 39 stable/… canonical -
libreoffice 6.0.3.2 59 stable canonical disabled
libreoffice 6.0.4.2 63 stable canonical -


Now there are so many disabled packages there which are no longer used. So I want to remove those packages. Here the command is snap remove gnome-3-26-1604 --revision=62 . Now I have to do it for all the revisions and for all the packages one by one. Is there any command which will remove the disabled or unused snap packages with single line of command?



Thanks in advance...


More From » package-management

 Answers
0

I'll look into adding this sometime soon (as a 20% thing). Meanwhile, you could drop


#!/bin/sh
set -eu

LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done

into a shell script and run that.


[#8209] Saturday, May 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fectlyole

Total Points: 64
Total Questions: 110
Total Answers: 110

Location: Nicaragua
Member since Thu, Feb 3, 2022
2 Years ago
;