Find the answer to your Linux question:
Results 1 to 6 of 6
Hi There, I am looking to delete all directories and files within the directories, from a directory. Every directory has the same folder within it, which I am looking to ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    3

    Newbie question about deleting multiple instances of a particular directory

    Hi There,

    I am looking to delete all directories and files within the directories, from a directory.

    Every directory has the same folder within it, which I am looking to remove, for example...

    /var/www/website/.svn/
    /var/www/website/folder1/.svn/
    /var/www/website/folder1/subfolder1/.svn/

    etc.

    How can I remove all the folders named .svn/ (and all subfiles) instantly?

    (If anyone is super clever and also knows the Windows command, that will save some Googling )

    So far I think I'm close with

    rm -Ri /var/www/ *.svn/

    Any ideas? Thanks guys.

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Hi and Welcome !

    Code:
    rm -rf  /var/www/website/.svn
    Above command will remove .svn folder including subfolders under .svn.

    Check manual of rm command. man rm
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    3
    Hi no that didnt work, but I found a solution for other peoples reference,

    find . -name .svn | xargs rm -vRf

    cheers

  4. #4
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Thats weird. I will look into this. AFAIK, rm -rf removes folders and subfolders instantly.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  5. #5
    Just Joined!
    Join Date
    Aug 2007
    Posts
    3
    Hi Yea, When I tried your method it just said "directory does not exist", because .svn wasn't in the root, it was in every other directory below it.

    Using the method I found, it did a search for all the .svn within all directories, then deleted them and the files.

    I tried for hours messing about with rm -rf [options] and I wasnt getting anywhere, hence why I posted here

    Thanks for your quick reply though, much appreciated, it led me to finding another solution.

    I will no doubt be trying to pick your brains on other topics if you don't mind

  6. #6
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    You are most welcome to ask for suggestion at any time.
    I think problem was directory path only.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •