Remove all files recursively without deleting directories

command linefindrm

I want to "clean out" all of the files a directory including all files in subdirectories but I want to leave the subdirectories in place. My understanding of rm -r is that it will also delete the subdirectories themselves.

I do not want to delete hidden (dot) files.

How can this be done?

Best Answer

Use find for that:

find . ! -name '.*' ! -type d -exec rm -- {} +
Related Question