I have a folder without around 500 subdirectories. There is a lot of trash to be found in it and I want to clean it up.

I have already deleted certain filetypes that I don't want, like images, with this command:

find . -mindepth 1 -iname "*.jpg" -type f -delete

However, I now want to delete all extension-less files. Files like "Shopping list" intead of "Shopping list.txt"

I have tried the following command but it did not work:

find . -mindepth 1 ! -iname "*.*" -type f -delete

2 Answers 2


Try this:

find . -type f  ! -name "*.*"  -delete

However, note that the above will not delete files whose name ends in a ., for example foo.. To delete those as well, use this instead:

find . -type f  ! -name "*.?*" -delete
  • The second command was my next question. Thanks so much! I could also type find . -type f ! -name "*?.*" -delete to remove files like ".trash" or whatever it was that I didn't need. Don't worry - it wasn't my Home directory, so I didn't lose any config files.
    – etsnyman
    May 15, 2014 at 8:43
  • 5
    @etsnyman Better to test first the command without the -delete option! May 15, 2014 at 8:44
  • @etsnyman not quite, to remove files that start with a dot, use find . -type f -name ".*" -delete the one in your last comment will also delete files with no extensions. And what Radu said! Test first!
    – terdon
    May 15, 2014 at 8:47
  • @RaduRădeanu I actually tested it first on a dummy directory with empty files...
    – etsnyman
    May 15, 2014 at 8:47
  • @terdon What does the question mark means in your second command? May 15, 2014 at 9:03

You could use:

find . -type f ! -name "*.*" -delete

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.