Saturday, May 4, 2024
33
rated 0 times [  33] [ 0]  / answers: 1 / hits: 31153  / 2 Years ago, fri, may 27, 2022, 2:37:49

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

More From » command-line

 Answers
1

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

[#25205] Saturday, May 28, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tinchir

Total Points: 300
Total Questions: 116
Total Answers: 119

Location: American Samoa
Member since Sun, Jan 17, 2021
3 Years ago
tinchir questions
Tue, Sep 14, 21, 23:11, 3 Years ago
Mon, Dec 19, 22, 13:00, 1 Year ago
Sat, Feb 5, 22, 11:36, 2 Years ago
Mon, Aug 8, 22, 02:16, 2 Years ago
;