Created
May 30, 2020 23:37
-
-
Save nottux/74fca7be9a1e22b9323ebd826463f93d to your computer and use it in GitHub Desktop.
This took ~two days but worth it
This file contains hidden or 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
#To list files& folders that going to be removed: | |
eval "echo !($((a=/home/utku;find /home/utku3 /mnt/old_drive/utku2 -type l -ls|sed 's/-> /\t/g;s/\\303\\266/ö/g;s/\\303\\274/ü/g'|cut -f 2|grep $a/;echo -e $a/took\\n$a/Belgeler\\n$a/İndirilenler)|sed s/$(echo $(pwd)|sed 's/\//\\\//g')//g|sed 's/\//\t/g'|cut -f 2|tr \\n '|'))" | |
#To remove said folders: | |
eval "sudo rm -rfv !($((a=/home/utku;find /home/utku3 /mnt/old_drive/utku2 -type l -ls|sed 's/-> /\t/g;s/\\303\\266/ö/g;s/\\303\\274/ü/g'|cut -f 2|grep $a/;echo -e $a/took\\n$a/Belgeler\\n$a/İndirilenler)|sed s/$(echo $(pwd)|sed 's/\//\\\//g')//g|sed 's/\//\t/g'|cut -f 2|tr \\n '|'))" | |
#Lists again but changed for utku2 | |
eval "echo !($((a=/home/utku2;find /home/utku3 /mnt/old_drive/utku -type l -ls|sed 's/-> /\t/g;s/\\303\\266/ö/g;s/\\303\\274/ü/g'|cut -f 2|grep $a/;echo -e $a/took\\n$a/Belgeler\\n$a/İndirilenler)|sed s/$(echo $(pwd)|sed 's/\//\\\//g')//g|sed 's/\//\t/g'|cut -f 2|tr \\n '|'))" | |
#You get the idea | |
#I have got bit more into sed with this and learnt a lot about bash yet again! | |
#I have like cleaned 50GB of garbage thanks to this | |
#Script can't see . files& folders and If you're in a linked folder it won't work and delete everything inside so they require manual work | |
#The above is the limitation of the said bash feature I use to say "folders except these in this directory": !() | |
#Also "find" for some reason doesn't support unicode, I have manually added some convertion to sed so it would work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment