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

Re: delete file based on content



On Mon, Jan 05, 2004 at 07:28:31PM -0500, Paul Morgan wrote:
> On Mon, 05 Jan 2004 18:18:00 -0600, Michael Martinell wrote:
> > #rm `grep -li "Processing completed correctly" *`
> > 
> > 
> > This worked nicely at the command line, however when I put in into a script
> > I received the error rm :too few arguments
> > 
> > Any other thoughts?
> > 
> 
> You would get that, at the command line or in a script, if there were no
> filenames returned by grep (i.e. none to delete).  You can check by simply
> typing "rm" by itself and you'll get the same error message.  To suppress
> the error message, you could do this:
> 
> 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.

-- 
Jan Minar                   "Please don't CC me, I'm subscribed." x 7

Attachment: pgpUbyMIt0O4p.pgp
Description: PGP signature


Reply to: