How can I delete every file on the system which have something in the name?
Asked
Active
Viewed 5,575 times
1 Answers
3
Please be careful
This following command with the parameter -delete deletes all the files with something in the name in the specified directory and in all subdirectories.
Open a terminal and go to the right folder:
cd <your_search_starts_here>
test with
find . -type f -name "*something*"
and delete with
find . -type f -name "*something*" -delete
Or a shorter version:
find <your_search_starts_here> -type f -name "*something*" -delete
For your home folder:
!!! first run a test
find ~ -type f -name "*something*"and than
find ~ -type f -name "*something*" -delete
For the whole filesystem
!!! first run a test !!!
sudo find / -type f -name "*something*"and test again and than delete with
sudo find / -type f -name "*something*" -delete
Or only in the specified directory:
find <your_search_starts_here> -maxdepth 1 -type f -name "*something*" -delete
And because you have used the tag locate:
The results of a search with locate are based on a database. This may be outdated. Start an update with sudo updatedb. find performs a true search. However, it also takes longer.
-
That's the problem `right folder` .. those files are all across the system and it will be pain to navigate it to each folder and delete them. – Goro May 18 '15 at 12:26
-
As I wrote "This command deletes all the files with `something` in the name in the specified directory and in all subdirectories." – A.B. May 18 '15 at 12:27
-
So there is no way to say `check the system, find "files" and delete them` without to say first `in this directory` as I said is too much time consuming if I navigate to each directory where it has the file and then delete it. – Goro May 18 '15 at 12:30
-
2
-
Thank's let me try it. It will be long long `find....` I will post the result. – Goro May 18 '15 at 12:36
-
Strange.. whit `locate file` It found really a lot of that file.. but with `sudo find / -type f -name "*something*"` it found only ~10-15 results. – Goro May 18 '15 at 12:41
-
Also it didn't delete any file whit `-delete`. All files are still on the system – Goro May 18 '15 at 12:44
-
The search with `locate` is based on a database. This may be outdated. Start an update with `sudo updatedb`. `find` performs a true search. However, it also takes longer. – A.B. May 18 '15 at 12:44
-
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/23889/discussion-between-a-b-and-goro). – A.B. May 18 '15 at 12:45