Site icon Bytefreaks.net

Remove Disabled Snaps.

Advertisements
LANG=C snap list --all | awk '/disabled/{print $1" --revision "$3}' | xargs -rn3 sudo snap remove;

Let us break down the command for you:

  1. LANG=C sets the language to English (C locale), which can be helpful to ensure consistent behavior across different systems with different default languages. We used this to make sure that the word disabled will appear for disabled snaps and not some other translation.
  2. snap list --all lists all installed snaps (i.e., packages) along with their details. The output of this command is piped to the following command.
  3. awk '/disabled/{print $1" --revision "$3}' searches for lines in the output that contain the word “disabled” and prints the first field (i.e., the name of the snap) followed by the string “–revision” and the third field (i.e., the revision number). This output is piped to the next command.
  4. xargs -rn3 sudo snap remove takes groups of three arguments from the input and runs the command snap remove with those arguments. In this case, the first argument is the name of the disabled snap; the second argument is the string “–revision”, and the third argument is the revision number. This will remove all disabled snaps and their associated revisions.

So, in summary, the command searches for all disabled snaps on the system, extracts their name and revision number and then removes them using the snap remove command. This is a very useful command to free up some space without losing data or functionality.

This post is also available in: Αγγλικα

Exit mobile version