Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: [ubuntu] Recursive command to remove dirs & files

  1. #1
    Join Date
    Jan 2014
    Location
    Statham,GA USA
    Beans
    212
    Distro
    Ubuntu 12.04 Precise Pangolin

    [ubuntu] Recursive command to remove dirs & files

    I have a file system that I need to remove part of it. I got into it, and there are myriad folders and files. I tried
    Code:
    sudo rmdir -R <foldername>
    and evidently the -R has been dropped from rmdir (I guess it is too dangerous for some to use).

    How can I remove the current folder and all child folders and files without having to spend all night cd.ing and rmdir.ing and rm.ing files?

    A response will save me several hours work.

    Thanks - Ben
    A to Z Answers to a lot of your questions....NewDocs.
    Book Download about 13.10.

  2. #2
    Join Date
    Jun 2007
    Location
    Waikikamukau, New Zealand
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: [ubuntu] Recursive command to remove dirs & files

    Thread moved to General Help.

    Forum Feedback and Help is for reporting technical problems with the website here (i.e. broken features), or ask questions pertaining to forum features.
    Forum DOs and DON'Ts
    Never assume that information you find using a search engine is up-to-date.

  3. #3
    Join Date
    Jan 2014
    Location
    Statham,GA USA
    Beans
    212
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [ubuntu] Recursive command to remove dirs & files

    Thank you lisati I was going to ask y'all to move it to General because I realised it was in the wrong place. You moved it without my asking. Thank you, Ben
    Last edited by bc.haynes; February 28th, 2014 at 02:58 AM. Reason: misspelling
    A to Z Answers to a lot of your questions....NewDocs.
    Book Download about 13.10.

  4. #4
    Join Date
    Apr 2012
    Beans
    5,906

    Re: [ubuntu] Recursive command to remove dirs & files

    The rmdir command only removes empty directories - to remove non-empty dirs you need to use rm

    Code:
    sudo rm -rf <foldername>
    BE ABSOLUTELY SURE YOU TYPE THE FOLDERNAME CORRECTLY - THERE IS NO UNDO. Be especially careful if the foldername contains special characters or spaces.

  5. #5
    Join Date
    Jan 2014
    Location
    Statham,GA USA
    Beans
    212
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [ubuntu] Recursive command to remove dirs & files

    Thank you, steeldriver, that's twice you have saved me some time & toil.

    Thanks for the heads-up warning.
    A to Z Answers to a lot of your questions....NewDocs.
    Book Download about 13.10.

  6. #6
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,020
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: [ubuntu] Recursive command to remove dirs & files

    EDIT: sorry late response.

    Hi bc.haynes.

    WARNING: there's no comeback if this you ran this on the wrong directory:
    Code:
    rm -rf foldername
    -r for recursive
    -f for force, no questions asked.

    Hope it helps. Let us know how it goes.
    Regards.

  7. #7
    Join Date
    Jan 2014
    Location
    Statham,GA USA
    Beans
    212
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [ubuntu] Recursive command to remove dirs & files

    This is how it went"
    Code:
    sent 138.91K bytes  received 12.73K bytes  101.10K bytes/sec
    total size is 172.13M  speedup is 1135.08 (DRY RUN)
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
    Code 23 is "Partial transfer due to error"
    Code:
    rsync -vaxzPXhn /Source/ /Destination
    Was what I used.

    What did I do wrong?
    A to Z Answers to a lot of your questions....NewDocs.
    Book Download about 13.10.

  8. #8
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,020
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: [ubuntu] Recursive command to remove dirs & files

    Were you able to remove recursively the directory you wanted to delete?

    How the 'rsync' command is related to your original concern? If it's not, opening another thread for that specific problem would get more attention to it.

    Regards.

  9. #9
    Join Date
    Jan 2014
    Location
    Statham,GA USA
    Beans
    212
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [ubuntu] Recursive command to remove dirs & files

    I did a -vv (very verbose) Dry Run and got this:
    Code:
    total: matches=0  hash_hits=0  false_alarms=0 data=0
    
    sent 135.68K bytes  received 12.83K bytes  99.00K bytes/sec
    total size is 171.68M  speedup is 1156.05 (DRY RUN)
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
    ben@MissionControl:~$
    I removed an old rsnapshoy dir & all children. Then I used the /snapshot directory to store rsync info on a USB pendrive.
    Last edited by bc.haynes; February 28th, 2014 at 05:06 AM. Reason: add"l info
    A to Z Answers to a lot of your questions....NewDocs.
    Book Download about 13.10.

  10. #10
    Join Date
    Jan 2014
    Location
    Statham,GA USA
    Beans
    212
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [ubuntu] Recursive command to remove dirs & files

    @ papibe - I shall do as you suggest and start a new thread about this.
    A to Z Answers to a lot of your questions....NewDocs.
    Book Download about 13.10.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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