Last active
August 29, 2015 13:59
-
-
Save Avinash-Raj/10476631 to your computer and use it in GitHub Desktop.
Shell script to remove all the 404 Not found PPA's automatically in Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#The below script will remove all the 404 Not Found PPA's automatically in Ubuntu | |
#Detailed execution of this script was posted here (http://askubuntu.com/a/432364/202806) | |
#This script takes some time according to your internet speed. | |
#Fell free to post the comments below. | |
if [ `whoami` != root ]; then | |
echo Please run this script using sudo | |
echo Just type “sudo !!” | |
exit | |
fi | |
sudo rm /tmp/update.txt; tput setaf 6; echo "Initializing.. Please Wait" | |
sudo apt-get update >> /tmp/update.txt 2>&1; awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt; sort -u /tmp/awk1.txt > /tmp/awk2.txt | |
tput sgr0 | |
if [ -s /tmp/awk2.txt ] | |
then | |
tput setaf 1 | |
printf "PPA's going to be removed\n%s\n" "$(cat /tmp/awk2.txt)" | |
tput sgr0 | |
while read -r line; do echo "sudo add-apt-repository -r ppa:$line"; done < /tmp/awk2.txt > out | |
bash out | |
else | |
tput setaf 1 | |
echo "No PPA's to be removed" | |
tput sgr0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment