Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
I am moving over my files from Windows, but Windows keeps packing all these *.ini and *.db files everywhere, and they are just sitting there, cluttering everything up and serving ...
  1. #1
    MTK
    MTK is offline
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    132

    How to delete files in subdirectories?

    I am moving over my files from Windows, but Windows keeps packing all these *.ini and *.db files everywhere, and they are just sitting there, cluttering everything up and serving no purpose in Linux.

    For example my Pictures folder, wich contains lots of subfolders within subfolders, a lot of them containing those pesky files. I tried:

    Code:
    $ rm -r *.db
    but it only deleted *.db files that are in the current directory, and the ones in subdirectories are still there. How do I remove all of them without having to manually go through each folder?

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    this should work, though its not that efficient, open a terminal and cd into your Pictures folder, execute this code
    Code:
    for i in `find . -name "*.db" && find . -name "*.ini"` ; do rm $i ; done

  3. #3
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70
    So do you just want to wipe everythig out? Basically nuke it?

    Would this work?


    rm -rf *.*

    Since you probably don't want to sit there saying yes to everything the -f option forces the deletion.

    rm -rf *

    That could work too, haven't tried it though.

  4. #4
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    845
    No!

    Your first command will delete everything with a . in it's name, the second will delete everything

    The original poster only wanted to delete certain files
    Linux User #453176

  5. #5
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70
    Quote Originally Posted by Kieren View Post
    No!

    Your first command will delete everything with a . in it's name, the second will delete everything

    The original poster only wanted to delete certain files


    Right ok, I wasn't sure if he was being specific with just .ini/.db files or he was just saying them as an example of some. But yes, my command would nuke everything.\


    If that's not what he wants, obviously just type the ending extensions that he would want to nuke...

  6. #6
    MTK
    MTK is offline
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    132
    Code:
    $ rm -rf *.db
    That didn't work.

    Note that I have this alias in my .bashrc file so I wouldn't accidentally delete some important files:

    Code:
    alias rm='rm -i'
    I don't know if that could interfere.

  7. #7
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70
    Quote Originally Posted by MTK View Post
    Code:
    $ rm -rf *.db
    That didn't work.

    Note that I have this alias in my .bashrc file so I wouldn't accidentally delete some important files:

    Code:
    alias rm='rm -i'
    I don't know if that could interfere.

    No that's ok. What you type manually overrides what's in your ALIAS.


    Try this.


    Code:
    $ rm -Rf *.db
    With a capital R.

  8. #8
    MTK
    MTK is offline
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    132
    Still nothing!

  9. #9
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    did you skip over my post?

  10. #10
    MTK
    MTK is offline
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    132
    It did work, but it seems like there should be an easy way to do it.

Page 1 of 2 1 2 LastLast

Posting Permissions

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