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

Re: delete file based on content



On Tue, Jan 06, 2004 at 08:10:44AM +0100, Jan Minar wrote:
> On Mon, Jan 05, 2004 at 07:28:31PM -0500, Paul Morgan wrote:
[snip]
> > 
> > rm `grep -li "Processing completed correctly" *` 2>/dev/null
> 
> This is ugly, Paul: It'd suppress not only this message, but other
> messages which would possibly be worth noticing.  Given sufficient
> number of executions, such a message will appear--and we would miss it.

How about 

if [[ `grep -li "Processing completed correctly" *` != "" ]]; then
  rm `grep -li "Processing completed correctly" *`
fi

although from what I've read in "The Unix Haters Handbook", Paul's way 
is more in line with the "unix philosophy" -- laziness.

In this case, you should expect rm files you can write to succeed ??



Reply to: