General Computing
linux command-line debian archiving
Updated Mon, 25 Jul 2022 15:27:31 GMT

How to remove all the parts of a split RAR archive file using command line?


Im generally use a Debian based Linux distribution of some sort; either Debian 7.8 or Linux Mint 17. I have a split RAR file like this:

filename.rar
filename.r01
filename.r02
filename.r03
etc ...

Having extracted the archive using dtrx or unrar, Id like to delete all the part files of the split archive using, preferably a single line.

At the moment I do rm filename.r*, which in general works well, however if the files are name like rabbid.ranger.robot.r01 it can delete the extracted directory rabbid.ranger.robot as well.

So Im looking for something a bit more robust.

Will accept a short script as well.




Solution

Depending on the number of .r0* files you have you could replace the * with a ? this will remove files that have .r0 and 1 other character. So it will remove rabbid.ranger.robot.r01 but not rabbid.ranger.robot.r010 Generally I would use it as such:

rm filename.r??