Delete Multiple files in Linux
Bypassing multiple filenames as arguments to rm, you can delete multiple files.
rm {file-name-1} {file-name-2} {file-name-3} ... {file-name-N}
Regular expressions are also supported by rm. If you want to delete all files with the name file-name-*, type:
rm file-name*.ext
Regular expressions may also be used to define different directories. We can use something like to delete three files that fit file-name-1, file-name-2, and file-name-3.
rm file-name-[123]
How to Delete Files in Linux?
Linux comes with several tools that can assist us in removing Directories and files. We always need to delete many files and folders based on a set of requirements. To complete our mission quickly, knowing a few basic commands and their variations is beneficial.
- Use caution when using the commands below, particularly those that use regular expressions or search patterns with the find command. An incorrect expression or pattern will result in the deletion of important data/system files and non-intended files.
- Often have a current copy of critical data and device files.
- Use caution when running those commands, particularly if you’re using Sudo or as the superuser (root).
Table of Content
- 1. Delete file by using “unlink” in Linux
- 2. Delete a single file in Linux
- 3. Delete Multiple files in Linux
- 4. Locate and Delete files in Linux
- 5. Empty files should be found and deleted
- 7. Permissions are used to locate and delete files
Contact Us