# find file



## cashua66 (Jan 30, 2011)

I want to find files which includes  string of "kernel32.dll". I use grep and find commands
but Ä± can't solve the problem. please reply my message.


----------



## cashua66 (Jan 30, 2011)

I want file which includes "kernel32.dll" and I want to delete those files. And I have to do this with shell programming


----------



## kisscool-fr (Jan 30, 2011)

what do you already tried ?


----------



## cashua66 (Jan 30, 2011)

In fact I want to delete virus files in my flash memory by shell prog. 
my codes is


```
cd /mnt

a=`grep -i kernel32.dll *`
find "$a" /mnt -type f > /home/cashua/file.sh
```
this code doesn't work. it writes all file names in file.sh
And I want to delete those files in list of file.sh


----------



## da1 (Jan 30, 2011)

If you want to delete using the find cmd, use 
	
	



```
find [...] -exec rm {} \;
```


----------



## kisscool-fr (Jan 30, 2011)

Take a look a the find(1) man page and specially the -delete option.


----------



## cashua66 (Jan 30, 2011)

How can do that can you write clearly


----------



## wblock@ (Jan 30, 2011)

See the find(1) man page as shown in post #6 (Nasc InchliceÃ¡ilte!).  Please also post a link to the homework assignment.


----------



## Alt (Jan 30, 2011)

```
find /mnt/flash -name '*kernel32.dll*' -delete
```


----------



## cashua66 (Jan 31, 2011)

I want to delete which file includes the string "kernell32.dll". Not file name kernel32.dll. Please help.


----------



## Fred (Jan 31, 2011)

You mean like, [cmd=]grep -lr kernel32.dll .|xargs -d '\n' rm[/cmd]
?



			
				wblock said:
			
		

> Please also post a link to the homework assignment.



I'm interested too.


----------



## wblock@ (Jan 31, 2011)

cashua66 said:
			
		

> I want to delete which file includes the string "kernell32.dll". Not file name kernel32.dll. Please help.



You may have noticed that many of us are kind of tiptoeing around the subject without just handing you the answer.  That's because just giving the answer really doesn't do anyone any favors.  It's better to help you learn how to do it, and how to look it up.

That said, here's a hint:
`% man find | less +/-exec`


----------



## Alt (Jan 31, 2011)

cashua66 said:
			
		

> I want to delete which file includes the string "kernell32.dll". Not file name kernel32.dll. Please help.


Repeating again.
	
	



```
find /mnt/flash -name '*kernel32.dll*' -delete
```

2 Other forum people: stop using KDE4/QT4/sed/awk/grep/less/exec/sudo/named/httpd/`ls /bin/` or other random thing you use. This elementary thing can be done with 1 command.


----------



## phoenix (Jan 31, 2011)

Alt:  that will delete files *named* kernel32.dll, not files that *include* the string "kernel32.dll".


----------



## Alt (Jan 31, 2011)

Duh if hes talking about file's content then
	
	



```
grep -lr "kernell32.dll" /mnt/flash | xargs -n 5 rm -rf
```
Note: if there is 2 "l" letters before "32.dll", then nvm.. otherwise this command can delete *.exe and *.dll !


----------

