I know this will delete everything in a subdirectory and below it:
rm -rf <subdir-name>
But how do you delete everything in the current directory as well as every subdirectory below it and the contents of all of those subdirectories?
I know this will delete everything in a subdirectory and below it:
rm -rf <subdir-name>
But how do you delete everything in the current directory as well as every subdirectory below it and the contents of all of those subdirectories?
Don't do it! It's dangerous! MAKE SURE YOU'RE IN THE RIGHT DIRECTORY!
This simplest safe & general solution is probably:
I believe this answer is better:
https://unix.stackexchange.com/questions/12593/how-to-remove-all-the-files-in-a-directory
basically you go up one level, and then say delete everything inside X directory. This way you are still specifying what folder should have its content deleted, which is safer than just saying 'delete everything here", while preserving the original folder, (which sometimes you want to because you aren't allowed or just don't want to modify the folder's existing permissions)
Practice safe computing. Simply go up one level in the hierarchy and don't use a wildcard expression:
The two dashes
--
tellrm
that<dir-to-remove>
is not a command-line option, even when it begins with a dash.