How do I delete all files and subdirectories in a directory in Linux?

How do I delete all files and subdirectories in a directory in Linux?
Answer
Open the terminal application. To delete everything in a directory run: rm /path/to/dir/* To remove all sub-directories and files:
rm -r /path/to/dir/*
…
Understanding rm command option that deleted all files in a directory
  1. -r : Remove directories and their contents recursively.
  2. -f : Force option. …
  3. -v : Verbose option.
 

Tìm kiếm

Back
Top