On Linux, what is the correct way to completely empty a directory without deleting it?
bash, filesystems, linux, unix
Solution
Try this :
find directory -mindepth 1 -delete
Problem
Obvious solutions such as `rm -rf directory/*` will forget hidden files, for example. What is the correct way to do this? My use case is the following: my directory is a subfolder of a root controlled directory, created by root and chowned to my user. If I delete it, I won't have the permissions to re-create it. However I want to make sure it's completely clean at the start of my process.