User Tools

Site Tools


deinstall_deinstall_state_packages_script

If you want to send us your comments, please do so. Thanks
More on comments


purgedeinstall.sh
#! /bin/bash
 
# File name: purgedeinstall.sh
 
# Files need to be in $HOME (/root)
# Cancel the purge and install files which not need to be purged first
# Run as root
 
# Check if aptitude is running
ps -e | grep aptitude > /dev/null 2>&1
exitcode=$?
if [[ $exitcode -eq 0 ]]; then
  echo aptitude is running. Please close aptitude and then run this script again. Thanks.
  exit 9
fi
 
# Deinstall packages with state deinstall found with dpkg --get-selections
dpkg --get-selections | grep deinstall | tr -s '\011' | tr '\011' '\n' | sort > $HOME/purgesort.txt
 
if [[ -s $HOME/purgesort.txt ]]; then
        # Remove the lines with 'deinstall'
        grep -v deinstall $HOME/purgesort.txt > $HOME/purgelist.txt
        cat $HOME/purgelist.txt
        cat $HOME/purgelist.txt | tr '\n' ' ' > $HOME/purge.txt
        while true; do
            read -p "Do you wish to purge those packages? [YN] " yn
            case $yn in
                [Yy]* ) xargs aptitude purge --assume-yes --purge-unused < $HOME/purge.txt
                        break;;
                [Nn]* ) exit;;
                * )     echo "Please answer 'Yes' or 'No'.";;
            esac
        done
else
        echo No packages to purge.
fi

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
deinstall_deinstall_state_packages_script.txt · Last modified: 19-08-2023 18:27 by wim