1

How can I delete every file on the system which have something in the name?

1
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.

9
  • 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
    Answered, read and please be careful. – A.B. May 18 '15 at 12:32
  • Thank's let me try it. It will be long long find.... I will post the result. – Goro May 18 '15 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.