views:

41

answers:

3

Hello all,

I'm working on a solaris box. How do I go about deleting all files in a folder, which have the word"Failure" in them ?

i'm trying something in the lines of the following, but it doesn't seem to remove anything.

rm -rf | find ./*.log -exec grep 'Failure' \;

Appreciate your inputs.

A: 
find . -type f -name \*Failure\* -exec rm {} \;
Tim
I'm trying the following, with no results :find . -exec grep "Failure" -exec rm {} \;
novice
A: 

You have to turn that around. Use find to locate the files and then use the -exec option with the rm command.

Brian Rasmussen
A: 

If I interpret correctly you don't require recursive searching, so something like:

rm -f `grep -m 1 'Failure' ./*.log | cut -d: -f1`

should work. If not, try:

rm -f `grep 'Failure' ./*.log | cut -d: -f1 | uniq`
mouviciel
I get an "grep: illegal option -- m" message. Any other suggestions ?
novice
Right, -m is not a portable grep option...
mouviciel
Thanks.. thats perfect :)
novice