In Unix, how do you remove everything in the current directory and below it?
Practice safe computing. Simply go up one level in the hierarchy and don't use a wildcard expression:
cd ..; rm -rf -- <dir-to-remove>
The two dashes --
tell rm
that <dir-to-remove>
is not a command-line option, even when it begins with a dash.
Will delete all files/directories below the current one.
find -mindepth 1 -delete
If you want to do the same with another directory whose name you have, you can just name that
find <name-of-directory> -mindepth 1 -delete
If you want to remove not only the sub-directories and files of it, but also the directory itself, omit -mindepth 1
. Do it without the -delete
to get a list of the things that will be removed.