Feral Cat

Building just because.

Delete a Folder and Its Children on a Mac or Linux Terminal

This is how you delete a folder and its children on a mac or linux terminal. Be careful because the f means force!

For those of Short on Time

rm -rf pathToYourFolder

Explanation of the Command

rm means remove on the command line. rm stuff.py would remove the stuff.py file. This doesn’t work when it’s presented folders. We would get a “rm: stuff: is a directory” error if stuff was a folder with children in it. That’s why we introduce -r which means to recursively do the action. The f means to force the deletion. So, “rm -rf stuff” means recursively and forcibly remove everything in the stuff folder.

I hope this was helpful when you try to delete a folder and its children on a mac or linux terminal. Check out this article if you’re interested in Python! Cheers and happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *