rm * will, by default, delete all files with names that don't begin with .. To delete all files and subdirectories from a directory, either enable the bash dotglob option so that * matches filenames beginning with .:
shopt -s dotglob
rm -r *
(The -r flag is needed to delete subdirectories and their contents as well.)
Use
rm *
from within the specific directory. The*
is a wildcard that matches all files.It will not remove subdirectories or files inside them. If you want that too, use
rm -r *
instead.But be careful!
rm
deletes, it does not move to trash!To be sure you delete the right files, you can use the interactive mode and it will ask for confirmation on every file with
rm -i *
rm *
will, by default, delete all files with names that don't begin with.
. To delete all files and subdirectories from a directory, either enable the bashdotglob
option so that*
matches filenames beginning with.
:(The
-r
flag is needed to delete subdirectories and their contents as well.)Or use
find
:The
-mindepth 1
option is to leave the directory itself alone.