rm delete recursively in linux/unix

How to use the rm command to delete files and directories recursively in linux/unix.

Syntax

rm -r dirName
rm -rf dirName

Examples

In the following example, recursively delete data folder:

➜  rm -r a

First clear all subdirectories, including their subdirectories and files, and then delete the data directory.

If the directory contains write-protected files, the user will be prompted to delete, unless the -f (force) option is used in the command line:

➜  rm -rf a

Tags:

Add a Comment

Your email address will not be published.