Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Unix command to delete two folders at once? Using rm -rf?

share|improve this question
add comment

migrated from stackoverflow.com Feb 8 '11 at 7:47

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 13 down vote accepted

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.

share|improve this answer
    
i don't know why i didn't just try this... –  funk-shun Feb 7 '11 at 8:05
add comment

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
share|improve this answer
3  
Its called "shell expansion" if anyone wants to look it up. –  Sirex Feb 8 '11 at 11:09
    
so thats what its called! i tried to search it but couldnt even form a good search criteria. –  kenny Feb 8 '11 at 11:13
add comment

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
share|improve this answer
    
good point, although I was looking more for a quicker (lazier) way to delete two folders –  funk-shun Feb 7 '11 at 8:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.