scripts

unixus scriptus
git clone https://s.sonu.ch/~roket1428/scripts.git
Log | Files | Refs

cleaner (474B)


      1 #!/bin/sh
      2 
      3 # simple script that removes unused packages
      4 
      5 # arch-linux based distros only
      6 
      7 { [ "$(whoami)" != "root" ] && echo "You must be a root user." >&2; } && exit 1
      8 
      9 output=0
     10 
     11 while [ "$(pacman -Qdt | wc -l)" -ge "1" ]
     12 do
     13 	pkglist=$(pacman -Qdt | sed -e 's/\ .*//g')
     14 	
     15 	for pkg in $pkglist
     16 	do
     17 		pacman -R "$pkg"
     18 		
     19 		output=$((output + 1))
     20 	done
     21 done
     22 
     23 if [ "$output" -ge "1" ] 
     24 then	
     25 	printf "%s package(s) removed.\\n" "$output"	
     26 else
     27 	printf "system is clean\\n"
     28 fi