Search anything:

rm multiple files

Internship at OpenGenus

Get this book -> Problems on Array: For Interviews and Competitive Programming

rm is a command on UNIX systems to delete files. In this article at OpenGenus, we have explained how to use this command rm to delete multiple files and other variants.

Table of contents:

  1. rm multiple files
  2. rm all files
  3. Variants of using rm
  4. Caution

rm multiple files

To delete multiple files at once using rm command, use the following command:

rm <file1> <file2> <file3>

rm all files

To delete all files in the present working directory (pwd), use asterisk (*) to select all files. The command is as follows:

rm *

In case, you would like to delete everything including directories, use rf option. The command is as follows:

rm -rf *

Variants of using rm

You can delete all files with a specific pattern. For example, if you want to delete all files with file extension .exe, use the following command:

rm *.exe

Similarly, if you want to delete all files that contain "closed" in its filename, use the following command:

rm *closed*

Note, there is an asterisk before and after the word closed.

To delete all files within a directory named "hen", use the following command:

rm hen/*

To delete everything including files and sub-directories within a directory named "murk", use the following command:

rm -rf murk/*

This will make the directory "murk" empty.


Remember, these are very powerful commands and you should use with full responsibility. If you are a beginner, try to avoid using these commands and even if you have to, delete files one by one only.

Only once you are a confident developer and are working in full sense, use these command carefully. Take care as many developers have accidently deleted important files. Recovering is an option but this will require an expert.

Aditya Chatterjee

Aditya Chatterjee

Aditya Chatterjee is an Independent Algorithmic Researcher, Software Developer and Technical Author. He is the founding member of OPENGENUS, an organization with focus on changing Internet consumption

Read More

Vote for Author of this article:

Improved & Reviewed by:

OpenGenus Tech Review Team OpenGenus Tech Review Team
rm multiple files
Share this