Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

What is the Command to Remove Files That Contain a Common String

Discussion in 'Getting Started' started by MinterTheMaladroit, Aug 10, 2018 at 11:54 AM.

  1. MinterTheMaladroit

    MinterTheMaladroit New Member

    Joined:
    Aug 3, 2018
    Messages:
    9
    Likes Received:
    1
    Hey,

    I installed Retroarch. However, something went wrong and I had to uninstall and reinstall the software several times. At last, I uninstalled the program in a weird way that I still have many associated files around the file system. I used a couple commands to get rid of them, but still got many.

    The command I am looking for should search the whole SSD for the files and folders containing the word "libretro" and delete them completely even though the process requires administrator rights (like sudo rm -r).

    Waiting for your replies,
    Thank you.


     
  2. Condobloke

    Condobloke Well-Known Member

    Joined:
    Apr 30, 2017
    Messages:
    224
    Likes Received:
    299
    perhaps you could run ubuntu cleaner....it may be running by default, or it may be in Software manager (like the PS Vita/qcma you were looking for...)

    only select the package confiogs and unneeded packages....hit clean and you should be fine

    [​IMG]
     
  3. atanere

    atanere Moderator
    Gold Supporter

    Joined:
    Apr 6, 2017
    Messages:
    1,459
    Likes Received:
    1,463
    You should not use a system-wide delete command unless you are REALLY SURE that it will perform as you expect.

    I would first search out your files with the find (or locate) commands to truly recognize the scope of your orphaned program files. It may not be as bad as you think.

    Sorry to not provide examples... worked all night and going to bed very soon. Google has plenty of tips on using find.

    Cheers
     
  4. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    250
    Likes Received:
    711
    I'll agree that you probably dont' want to do a system wide .. however..

    Code:
    for m in $(grep -ril "libretro" /path/to/start/);do rm -rf "$m";done
    you can test what it will delete by running:

    Code:
    for m in $(grep -ril "libretro" /path/to/start/);do echo $m;done
    grep:
    r (recursive)
    i (don't match case)
    l (list only the path/filenames, not the match)
     
    atanere likes this.
  5. MinterTheMaladroit

    MinterTheMaladroit New Member

    Joined:
    Aug 3, 2018
    Messages:
    9
    Likes Received:
    1
    Well, I am getting this error upon executing the commands above: "grep: /path/to/start/: No such file or directory"
     
  6. atanere

    atanere Moderator
    Gold Supporter

    Joined:
    Apr 6, 2017
    Messages:
    1,459
    Likes Received:
    1,463
    /path/to/start is just an example... you enter in the real path from where you want to begin your search.

    So, you could enter /home to start searching from there, which would include you and any other users on your system.

    Or you could just use / by itself to search your entire hard drive. Keep in mind that this may take awhile to complete!
     
  7. MinterTheMaladroit

    MinterTheMaladroit New Member

    Joined:
    Aug 3, 2018
    Messages:
    9
    Likes Received:
    1
    Sorry, I noticed that just after posting the reply.
    I ran the second command starting from the root directory. I will inform you after executing the first command. Thank you.
     
    atanere likes this.
  8. MinterTheMaladroit

    MinterTheMaladroit New Member

    Joined:
    Aug 3, 2018
    Messages:
    9
    Likes Received:
    1
    This is the output I got after executing the first command. I declare that it did not work as I expected.

    Is there any way to remove the files manually? I can search for them, select all and remove them but it won't let me delete these files.
     
    #8 MinterTheMaladroit, Aug 11, 2018 at 8:35 AM
    Last edited: Aug 11, 2018 at 8:41 AM
  9. atanere

    atanere Moderator
    Gold Supporter

    Joined:
    Apr 6, 2017
    Messages:
    1,459
    Likes Received:
    1,463
    You ran the 2nd command first... which was good, so to test the results. I think that should have listed all the places where it found "libretro".... did that work as expected?

    If the test command worked as expected, then it may be that all the "libretro" files were deleted with the 1st command, except those in /proc which it did not allow you to access.

    You said there were many "libretro" files.... are they still there now?
     
  10. MinterTheMaladroit

    MinterTheMaladroit New Member

    Joined:
    Aug 3, 2018
    Messages:
    9
    Likes Received:
    1
    Both of the commands failed, they did not work as expected. There are still 172 libretro files.
     
  11. atanere

    atanere Moderator
    Gold Supporter

    Joined:
    Apr 6, 2017
    Messages:
    1,459
    Likes Received:
    1,463
    You should not have run the delete command if the test did not work. That's very risky!

    I'm at work on my phone, so I can't troubleshoot the test command myself. But you can work with it to try to see what's going on. For /path/to/start... use a known path to where some of those files really are.... that might be /home or /home/your-username.... but be sure the command should work. Then if it doesn't, note the errors it gives and see if you can modify it to work correctly.

    I'm guessing that the command may be aborting after it fails in /proc. It may be that using / by itself is not a good choice to begin.
     

Share This Page