You can delete multiple files in bulk in Unix or Linux using the following methods:
- Using the
rm
command:
rm file1 file2 file3 ...
For example, to delete the files file1.txt
, file2.txt
, and file3.txt
, you would run the following command:
rm file1.txt file2.txt file3.txt
- Using wildcards:
rm *.txt
For example, to delete all .txt
files in the current directory, you would run the following command:
rm *.txt
Note that once you delete files with rm
, they are permanently gone and cannot be recovered. Before using rm
, make sure you understand what you’re doing and the potential consequences. You can use the rm
command with the -i
option to prompt for confirmation before deleting each file.
rm -i file1.txt file2.txt file3.txt
Also, be careful when using wildcards, as they can potentially delete more files than you intended. For example, rm *
will delete all files in the current directory, including hidden files.