I use Ubuntu 14.04 LTS. I tried rm 'ls'
, rm rf
but they did not work.
Asked
Active
Viewed 2.7e+01k times
68
2 Answers
83
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 *

Byte Commander
- 107,489
-
12
- doesn't match hidden files. You'll need to explicitly reference
– Artem Russakovskii Aug 06 '19 at 07:02.*
for those. - doesn't match hidden files. You'll need to explicitly reference
-
1If you want to remove both visible and hidden files and folders you can call:
rm -r * .*
– Artur Müller Romanov Jul 03 '22 at 18:19
27
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.)
Or use find
:
find . -mindepth 1 -delete
# or
find . -mindepth 1 -exec rm -r -- {} +
The -mindepth 1
option is to leave the directory itself alone.

muru
- 197,895
- 55
- 485
- 740
-
Let's say i'm emptying a Trash folder. Would "find . -mindepth 1 -delete" follow symlinks, thus delete things in external folders? – Motsel Jun 13 '18 at 22:36
-
3
rm -fr * .*
does the job as well..*
does not match..
or.
, to be safe. – Artem Russakovskii Aug 06 '19 at 07:04 -
I never tried this, but Filename expansion allows regexes, thus excluding the
..
reference:rm -rf * .[^.]*
but this still omits unusual filenames beginning with 2 or more dots such as..foobar
. – eel ghEEz Nov 26 '20 at 01:40 -
@eelghEEz Filename expansion most definitely does not allow regexes - it does have similarities in the syntax, but not in the semantics. Extended globbing does have regular semantics, but doesn't match the syntax. – muru Nov 26 '20 at 01:57
-
1@ArtemRussakovskii -- depends on your shell. for instance, bash excludes
.
and..
butsh
includes them. but, TIL bash does not. – keithpjolley Sep 21 '22 at 11:56
For just deletion of files on current directory:
– Techjail Mar 01 '16 at 13:46rm ./*
and For deletion of files and folders inside in isrm -R ./*
if you want no prompt mode, there is always-f
parameter for that