Remove directory contents but not directory itself

Publication date
07/30/2007
Categories
, ,
$ find directory_name -mindepth 1 -maxdepth 1 -exec rm -rf {} \;

where -maxdepth 1 -exec rm -rf {} \; deletes the directory files while -mindepth 1 avoids deleting the directory itself.

Comment this post

Fields marked with * are required.

*
It won't be made public. If you have a gravatar it will be displayed.
*