I think this is probably very easy, but since I couldn't find a solution I thought I'd ask here...
I know how to use the locate command to search the locate database for files and I know how to delete files using rm, but I can't find an easy way to link the two together. I've read a few tutorials on how to write basic sh scripts, but for some reason this seems harder than I would assume it would be. I just want a script where I can type something like the following...
sudo locate_delete foo
and it will delete any file that has the word foo anywhere in its path, anywhere on the hard drive. I know that this sounds like a very dangerous thing to do, but its being used to possibly solve an issue where the current solution is to just format the hard drive and re-image. Once a proof-of-concept is working I can probably get someone to take a closer look at the problem and hopefully find a more elegant solution.
BTW, I know I could use the find command mixed with sed to do something along these lines, but the final script is going to be looking for literally hundreds, perhaps thousands, of things to delete and thus would be way to slow actually searching for each file on each iteration. Pulling things out of the locate database would be faster by a large factor.