Unix command to delete two folders at once?

Yes:

rm -rf /path/to/folder1 /other/folder/in/different/place

The '-f' is not mandatory if you can write to each file and directory, or if you don't mind being asked lots of questions. The directories are deleted sequentially, but both are deleted as the result of a single command.


In bash, there is a way to insert a list of arguments with curly braces:

rm -rf /path/to/{folder1,folder2}
will run
rm -rf /path/to/folder1 /path/to/folder2

It can be inserted anywhere:

rm -rf /{folder1,folder2}/subfolder
will run
rm -rf /folder1/subfolder /folder2/subfolder

If you want the deletion to actually be concurrent, which can be faster if they are on separate disks, but probably slower if they are on the same one:

rm -rf /path/to/folder1 &
rm -rf /other/folder/in/different/place

Tags:

Unix