This script automates the removal of packages listed in one file (to_be_removed.txt
), but skips removal if doing so would also remove any "protected" packages listed in another file (keep.txt
). It ensures important packages are not accidentally uninstalled.
-
Prepare two text files:
to_be_removed.txt
: Packages you want to remove (one per line)keep.txt
: Packages that must not be removed (protected packages)
-
Run the script in a bash environment. It will simulate removal for each package in
to_be_removed.tx
. -
If any protected package would be removed as a side effect, the script skips removing that package.
-
Otherwise, it proceeds to remove the package using
apt-get remove -y
.