开发者

Removing all files from a folder with by searching for a string in unix

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.


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`


find . -type f -name \*Failure\* -exec rm {} \;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜