Sometimes, we need to delete all the files searched by locate command. What we do ( i do this before :P) is to go to those files path and delete them manually, one by one, which was a tedious job.
So to do this using command, type:
$locate <search-string> | xargs rm -Rf
What xargs does is take a line from the input, and append it to another command, executing that other command for every line in the input. So by typing
locate foobar | xargs rm -f, the output of the locate command will be patched onto the end of the
rm -f command, and executed for each line produced by
You can verify the result by executing $locate <search-string> command again. If you still see those files after terminal, Probably case is your database of locate command is not updated after removing files, so to do this you need to give command to update the database of locate. I had same case and my friend mandeep helped me with this command 🙂