Recursively delete unwanted files

This command is to be used when you’ve installed something that won’t uninstall, or scattered certain files in many different places, and would like to remove them all quickly.

The command will search from root, looking for anything matching the filename pattern (in this case, we’re looking for “xscreensaver” files), and delete the files found. It needs to be run from within the Terminal:

sudo find / -name xscreen* -exec rm -rf {} \;

NOTE: Make sure there is a space between {} and \;

IMPORTANT! This is a potentially dangerous command, since it does not prompt you about deleting the files. If you use a wildcard (like the * ) and it matches files you didn’t expect, you could damage your system so that it will not start. Therefore, unless you are 100% sure of what you are doing, and can deal with the consequences if you make a mistake, I highly recommend the following:

Run your command without “rm” first, and send the output into a text file:

sudo find / -name xscreen* > x.txt

This will send the results to a text file that you can browse before you do the actual deleting.

By practic on August 3, 2011 | | 2 comments