To clean or not to clean?


As I was looking today at the searches performed on this blog. This bit (top picture) struck me. 😆

“Command not found” or “Not implemented”

Anyway the script goes here and the credit should and foremost go to the one who created the original???:

#!/bin/bash

OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
RED="\033[0;31m"
BLUE="\033[1;34m"
CYAN="\033[1;36m"
YELLOW="\033[1;33m"
NC="\033[0m"
#if [ $USER != root ]; then # <-- uncomment
#  echo -e $RED"   Only root can do this!" # <-- uncomment
#  echo -e $CYAN"    Error: In order to use this script, one must NOT be $USER" # <-- uncomment
#  echo -e $CYAN"    Hint: Use 'sudo -s' and try again."  # <-- uncomment
#  echo -e $YELLOW"    Exiting..."$NC # <-- uncomment
#  exit 0 # <-- uncomment
#else # <-- uncomment
#  echo "" # <-- uncomment
#  echo -e $BLUE"    $USER may proceed."  # <-- uncomment
#  echo -e $CYAN"    May peace be with you."$NC # <-- uncomment
#fi # <-- uncomment
clear
echo "------------------------------------------------------------------------------"
echo
echo -e $BLUE"Cleaning apt cache..."$NC
echo -e $CYAN"apt-get clean"$NC
# apt-get clean  # <-- uncomment
echo
echo "------------------------------------------------------------------------------"
echo
echo -e $BLUE"Removing old config files..."$NC
echo -e $CYAN"aptitude purge $OLDCONF"$NC
# aptitude purge $OLDCONF # <-- uncomment
echo
echo "------------------------------------------------------------------------------"
echo
echo -e $BLUE"Removing old kernels..."$NC
echo -e $CYAN"aptitude purge $OLDKERNELS"$NC
# aptitude purge $OLDKERNELS # <-- uncomment
echo
echo "------------------------------------------------------------------------------"
echo
echo -e $BLUE"Emptying every trashes..."$NC
echo -e $CYAN"rm -rf /home/*/.local/share/Trash/*/** &> /dev/null"$NC
echo -e $CYAN"rm -rf /root/.local/share/Trash/*/** &> /dev/null"$NC
# rm -rf /home/*/.local/share/Trash/*/** &> /dev/null # <-- uncomment
# rm -rf /root/.local/share/Trash/*/** &> /dev/null # <-- uncomment
echo
echo "------------------------------------------------------------------------------"
echo -e $YELLOW"    Script Finished!"$NC
echo
echo -e $YELLOW"    My job is done."$NC
echo -e $YELLOW"    Have a nice day!"$NC
echo
exit 0

3 thoughts on “To clean or not to clean?

  1. Pingback: Motivation And Personality – Know Your Type | Self Improvement Talk

Comments are closed.