Friday, April 24, 2015

rmdir - Python Tutorial

rmdir – Allows us to remove directories via the terminal. This command makes for an easier and quicker way to remove folders. If your directory contains files or folders the rmdir will not work. The Work around to delete a directory that contains folders or files we need to use rm -rf folder name to delete that directory. Be Careful you do not delete an important directory or files there is no returning from this.


rmdir Example


#Find a file to delete
Thomass-MBP:desktop Tommy$ ls
Screen Shot 2015-03-02 at 9.17.06 AM.png
Screen Shot 2015-03-02 at 9.20.35 AM.png
Screen Shot 2015-03-02 at 9.28.59 AM.png
Screen Shot 2015-03-02 at 9.35.50 AM.png
django
learnPython
manage.py
movies
projects
python
test
videos
web developement notes
wizardtut.py

#We will remove Test
Thomass-MBP:desktop Tommy$ rmdir test
Thomass-MBP:desktop Tommy$ ls
Screen Shot 2015-03-02 at 9.17.06 AM.png
Screen Shot 2015-03-02 at 9.20.35 AM.png
Screen Shot 2015-03-02 at 9.28.59 AM.png
Screen Shot 2015-03-02 at 9.35.50 AM.png
django
learnPython
manage.py
movies
projects
python
videos
web developement notes
wizardtut.py

#Remove a directory that contains folders and files
Thomass-MBP:desktop Tommy$ mkdir test
Thomass-MBP:desktop Tommy$ cd test
Thomass-MBP:test Tommy$ touch test.py
Thomass-MBP:test Tommy$ ls
test.py
Thomass-MBP:test Tommy$ cd ..
Thomass-MBP:desktop Tommy$ ls
Screen Shot 2015-03-02 at 9.17.06 AM.png
Screen Shot 2015-03-02 at 9.20.35 AM.png
Screen Shot 2015-03-02 at 9.28.59 AM.png
Screen Shot 2015-03-02 at 9.35.50 AM.png
django
learnPython
manage.py
movies
projects
python
test
videos
web developement notes
wizardtut.py
Thomass-MBP:desktop Tommy$ rm -rf test
Thomass-MBP:desktop Tommy$ ls
Screen Shot 2015-03-02 at 9.17.06 AM.png
Screen Shot 2015-03-02 at 9.20.35 AM.png
Screen Shot 2015-03-02 at 9.28.59 AM.png
Screen Shot 2015-03-02 at 9.35.50 AM.png
django
learnPython
manage.py
movies
projects
python
videos
web developement notes
wizardtut.py
Thomass-MBP:desktop Tommy$

 



No comments:

Post a Comment