Dimitris Filippou Dimitris Filippou - 1 month ago 17
Linux Question

Get files from locate , Then remove them

After removing packages , some of them leave files behind that i don't really use , so i want to remove them rather than restoring the whole server from scratch.

I use

sudo locate logstash


I get a long list of files and directories , and i want to delete them.

There is an oldschool way that i've seen , and that's putting this list to a file.txt and then read it line by line and remove it.

Is there any faster bash way to remove these items shown in this list?

In addition , how can i tell if it's a directory or a file ? ( to remove simply or recursive )

sat sat
Answer

You can try this:

locate logstash | xargs rm -rf 

Note: Make sure that locate gives you valid files that you want to delete.

Comments