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

RE: delete file based on content



On Mon, 05 Jan 2004 18:18:00 -0600, Michael Martinell wrote:

> Please ignore former post.  It was an ID10T error on my part.
> 
> 
> 
> -----Original Message-----
> From: Tom [mailto:40101.nospam@comcast.net] 
> Sent: Monday, January 05, 2004 5:41 PM
> To: debian-user@lists.debian.org
> Subject: Re: delete file based on content
> 
> On Mon, Jan 05, 2004 at 05:35:26PM -0600, Michael Martinell wrote:
> [snip]
>> 
>> 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 `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

man bash
/^REDIRECTION

...for information on what I added.

-- 
....................paul

Programming without a hex editor is like watchmaking without a hammer.




Reply to: