As the question suggests, I have a situation where I have a folder that users can upload weird stuff there. Have a cron job set up to clean this folder every a few hours.
It has a .htaccess for security reasons, of course, my question is, how can I delete everything (files and directories) in that directory, including hidden ones whose name start with a dot, but not the .htaccess?
I currently have rm -rf *
to do the job but if the user uploads a file with a name starting with a dot, it would not be deleted.
Any help would be much appreciated. Thanks!
.htaccess
to a new directory, remove the whole directory at once, then rename the directory back? – Alvin Wong Dec 29 '12 at 10:28mkdir newDir; cp uploadDir/.haccess newDir; rmdir uploadDir; mv newDir uploadDir;
– mcalex Dec 29 '12 at 11:26