72

I use Ubuntu 14.04 LTS. I tried rm 'ls', rm rf but they did not work.

muru
  • 207,228
alhelal
  • 2,741

2 Answers2

90

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
  • 110,243
31

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
  • 207,228