Sunday, September 30, 2012

Creating and Deleting Directories

"mkdir"  command

          used to create directories. 
  
eg: creating a directory using mkdir

  $ mkdir mydir1
  $ ls
   exit.png  Library.sql  mydir1  out1-1.ogv 


     creating multiple directories using mkdir

$ mkdir mydir2 mydir3
$ ls
exit.png  Library.sql  mydir1  mydir2  mydir3  out1-1.ogv  


"rmdir" command 

      used to delete directories

  eg: deleting a single directory

       $rm mydir1
       $ls
       exit.png  Library.sql mydir2 mydir3 out1-1.ogv 

      deleting multiple directories

       $ rmdir mydir2 mydir3
       $ ls
       exit.png  Library.sql  mydir1  out1-1.ogv 



     but you will get an error saying  rmdir: failed to remove `directory name': Directory not empty if you try to delete a directory containing files.

To forcefully delete directories containing files we have to use "rm" command with command line argument -rf

 ex:
     $ rmdir -rf mydir1



No comments:

Post a Comment