Remove all files recursively without deleting directories


To “clean out” all of the files a directory including all files in subdirectories, but ┬áleaving the subdirectories in place, just type the following command on your linux shell:

find . ! -name ‘.*’ ! -type d -exec rm — {} +


To avoid to delete hidden (dot) files, type:

find . -name ‘.?*’ -prune -o ! -type d -exec rm {} +

Leave a comment

Your email address will not be published. Required fields are marked *