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

MinterTheMaladroit

New Member
Joined
Aug 3, 2018
Messages
11
Reaction score
2
Credits
0
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.
 


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

ubuntu_cleaner.png
 
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
 
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)
 
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)
Well, I am getting this error upon executing the commands above: "grep: /path/to/start/: No such file or directory"
 
/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!
 
/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!
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.
 
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.
 
Last edited:
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?
 
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?
Both of the commands failed, they did not work as expected. There are still 172 libretro files.
 
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.
 

Members online


Top