You are not logged in.

#1 2016-04-24 15:02:42

MrRoberts
Member
Registered: 2012-07-05
Posts: 47

Find and delete using part of a name?

I'm connecting to an external drive that was part of Windows (/run/media/neo/SAMSUNG/) and trying to delete more than one file.

Hundreds of infected file names look like this...

-!RecOveR!-orcji++.Htm
-!RecOveR!-pdkgr++.Txt

How do I issue a command to search for the above file names and delete them?

Offline

#2 2016-04-24 15:12:14

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Find and delete using part of a name?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2016-04-24 15:17:07

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,793

Re: Find and delete using part of a name?

Try the find command

find path -name \-\!RecOveR\!\-\* 
where path is the root directory that contains the files.   If that creates a list of said files, then redirect the output to a file using >
find path -name \-\!RecOveR\!\-\* > foo 
Audit foo carefully.  Then do rm < foo   But be carefull.  This is not a perfect solution and the file names could need some escaping of characters.

Edit:  Snaked by Graysky

Last edited by ewaller (2016-04-24 15:18:17)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2016-04-24 15:31:43

MrRoberts
Member
Registered: 2012-07-05
Posts: 47

Re: Find and delete using part of a name?

Thank you, ewaller for your quick explanation

This is what I've done so far and the foo list shows what I'm looking for.

find /run/media/neo/SAMSUNG/ -name \-\!RecOveR\!\-\* > foo

Now, how do I correctly delete those files? Just want to hear from you before I do anything.

Last edited by MrRoberts (2016-04-24 15:43:58)

Offline

#5 2016-04-24 15:48:51

MrRoberts
Member
Registered: 2012-07-05
Posts: 47

Re: Find and delete using part of a name?

Managed to find and delete those files successfully.

Thanks again, ewaller

Offline

#6 2016-04-24 19:26:32

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Find and delete using part of a name?

Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB