Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 7 down vote accepted

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
share|improve this answer
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 '14 at 8:43
@etsnyman Better to test first the command without the -delete option! – Radu Rădeanu May 15 '14 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 '14 at 8:47
@RaduRădeanu I actually tested it first on a dummy directory with empty files... – etsnyman May 15 '14 at 8:47
@terdon Thanks! – etsnyman May 15 '14 at 8:48

You could use:

find . -type f ! -name "*.*" -delete
share|improve this answer
It worked! Thanks! – etsnyman May 15 '14 at 8:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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