Re: delete file based on content
On Mon, Jan 05, 2004 at 11:26:51PM -0800, Nano Nano wrote:
> 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.
>
You could use rm -f which will ignore empty files (this is how it is
usually used in the clean directive in make files.
I am not sure how the proposed method will work with files containing
spaces btw.
> In this case, you should expect rm files you can write to succeed ??
>
>
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
Reply to: