Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # WARNING: This script will attempt to delete all files containing the
- # string given to it as an argument. Do not run unless you know what
- # you're doing. You should have already located every file with this
- # string and decided that it can be deleted. This can easily break your
- # system, especially if run as root. It creates a backup at ~/rmbackup.
- # If run as root, that is /root/rmbackup
- #
- # There is probably a more concise way to do this with only one loop, but
- # I didn't feel like figuring out how to fix the directory structure
- # problems for the backup when you combine the loops as is.
- #
- # sh choosename.sh [regexp]
- mkdir $HOME/rmbackup
- sudo updatedb
- while read line; do
- directorystate=$(cd $line 2>&1 >/dev/null | grep "Not a directory")
- if [[ $directorystate ]]; then
- mkdir -p $HOME/rmbackup$line
- rm -rf $HOME/rmbackup$line
- rsync -raAX $line $HOME/rmbackup$line
- else
- mkdir -p $HOME/rmbackup$line
- fi
- done <<< "$(locate $@)"
- while read line; do
- directorystate=$(cd $line 2>&1 >/dev/null | grep "Not a directory")
- if [[ $directorystate ]]; then
- rm $line
- else
- rm -rf $line
- fi
- done <<< "$(locate $@)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement