[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: delete file based on content



On Mon, 2004-01-05 at 18:35, Michael Martinell wrote:
> Can anybody tell me what I am doing wrong? 
> 
> I am trying to delete files based upon content.  As an example I have
> files called log1, log2, log3 
> 
> Log 1 contains the words “Processing completed correctly” and can be
> deleted. 
> 
> I tried the following: grep –li “Processing completed correctly” *  
> 
> This gave me the list of logs that were complete.  How can I send the
> results of this to the rm command.  The redirection that I tried did
> not seem to work.

rm -f $(grep -li “Processing completed correctly” * | cut -f1 -d: | sort
| uniq )

That will get you the proper command. Now run along and read up on
"bash" with "man bash"

It is a good read for those that don't understand it, but want to use
its functionality.
-- 
greg@gregfolkert.net
REMEMBER ED CURRY! http://www.iwethey.org/ed_curry

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: