Equivalent of `apt autoremove` for zypper (or removing unneeded packages using zypper)

zypper pa --unneeded | grep '^i' | cut -d\| -f3 | xargs sudo zypper -n remove
  • zypper pa --unneeded lists unneeded packages.
  • grep '^i' selects lines that starts with i (installed package)
  • cut d\| -f3 selects third field after cutting line at delimited |
  • And the last one runs sudo zypper -n remove on the output.

On older version of zypper, following script may be useful.

https://github.com/dilawar/Scripts/blob/master/zypper_autoremove.sh

Leave a Reply