Linux Command Line Trick: Delete Directory
You can use the “rm” operation to delete a file form the command line, but what about if you want to delete a full directory?
Simply type the following into your command line:
$ rm -fr directory_name
.
Here is an example if you also want to try it out in your command line:
# clone this directory
$ git clone https://github.com/sharksforcheap/CLI-Obstacle-Course
# go into the new CLI-Obstacle-Course directory
$ cd CLI-Obstacle-Course
# locate the directory “delete_me”
$ find . -name delete_me
./delete_me #the delete_me directory is in the current directory
# delete the “delete_me” directory
$ rm -fr delete_me
$ find . -name delete_me
# the directory has been deleted, so nothing is returned