#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    22
    Rep Power
    0

    problem of removing subdirectory of a directory


    I find out cannot remove the directory that contain file and another subdirectory by using command

    rmdir -f dir_name

    so, everytime i hv to clear out the content of directory in order to delete the directory. So, anyone can teach me how to solve this problem? thanks~
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    137
    Rep Power
    0
    rm has this option. See man rm for all options

    rm -rf dir_name

    -r, -R, --recursive
    remove the contents of directories recursively

    -f, --force
    ignore nonexistent files, never prompt

    A warning: linux (and unix) are relentless, they do what you ask and don'y ask if you are sure!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    22
    Rep Power
    0
    druuna, thanks again~
    I am a beginner of Unix OS, so i still not familiar with those command..
    By the way, u r a very good tutor for me~ Have a nice day!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    India
    Posts
    61
    Rep Power
    11
    One small addition, You need to use "rm -rf" cautiously, if you tend to give "rm -rRf" * then the whole of the files from the root directory will be gets deleted. You better give rm -ri rather than rm -rf

    -i option will ask for confirmation before deleting the files
    Regards
    JK
  8. #5
  9. No Profile Picture
    Got source?
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2003
    Location
    Laguna Niguel, California, USA
    Posts
    2,331
    Rep Power
    14
    It will ask for confirmation if you don't include -i or -f. If you know what you are doing, -f is a better solution especially if you have a lot of files, as it would be very annoying to have to say yes many times needlesly.

IMN logo majestic logo threadwatch logo seochat tools logo