# poor-man antivirus



## fluca1978 (Dec 2, 2011)

Hi all,
my usb key has been infected by a windows virus, so that now in all my folders I've got a .exe file with the same name of the folder itself. Removing them was quite easy, since I had no windows executable on the key:


```
find /media/usb -name '*.exe' -print0 | xargs -0 rm
```

I was thinking about a one liner that would ensure me to erase only those exe that have the same name of the folder they are into. Any idea?


----------



## funky (Dec 2, 2011)

`$ find /media/usb -type d -exec rm -f '{}'.exe \;`


----------



## fluca1978 (Dec 3, 2011)

Nice, but probably it should be:

`$ find /media/usb -type d -[b]execdir [/b]rm -f '{}'.exe \;`


----------



## fonz (Dec 3, 2011)

fluca1978 said:
			
		

> Nice, but probably it should be:
> 
> `$ find /media/usb -type d -[b]execdir [/b]rm -f '{}'.exe \;`


Why do you think the latter is better? I don't think it makes a difference in this case:

```
$ mkdir -p dir1/dir2/dir3
$ find dir1 -type d -exec echo '{}'.exe \;
dir1/dir1.exe
dir1/dir2/dir2.exe
dir1/dir2/dir3/dir3.exe
$ find dir1 -type d -execdir echo '{}'.exe \;
dir1.exe
dir2.exe
dir3.exe
```
Seems pretty much equivalent to me.

Fonz


----------



## fluca1978 (Dec 5, 2011)

You are right, they are equivalent.
I tend however to prefer the one that drops me in the directory since I feel a little more secure in the case I've mispelled any argument...


----------

