Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Delete a directory – Terminal

Summary

To delete an empty directory using your terminal, enter the following command:

rmdir folder-name

Details

The above command only works if the directory is empty. If the directory isn’t empty, you will see the following print out:

rmdir: folder-name: Directory not empty

Delete multiple folders

To delete multiple folders, pass in multiple folder names as arguments to the rmdir command, like this:

rmdir folder-1 folder-2

Exercises

Try the following command in your project folder:

rmdir css

You should see the following print out:

rmdir: css: Directory not empty

Then run the following commands:

rm css/style.css
rmdir css

References

Command Line Primer on the Apple Developer Archive (see the section called Frequently Used Commands)

Back to: Terminal Reference > Terminal Advanced Commands