[ale] Need some scripting assistance

JK jknapka at kneuro.net
Wed Jun 28 13:03:05 EDT 2006


Byron A Jeff wrote:

>On Wed, Jun 28, 2006 at 10:51:33AM -0400, Ryan Fish wrote:
>  
>
>>I am in need of help with figuring out how to grep for "mail.panteq.com"
>>within /var/spool/mqueue/* and deleting every message that contains this
>>string.
>>    
>>
>
>Try this on for size (note it is only minimally tested):
>
>################# cut here #######################
>#!/bin/bash
>for mail in /var/spool/mqueue/* ; do
>  grep -q "mail\.panteq\.com" "$mail" && rm -i $mail
>done
>################# cut here #######################
>
>If you feel real sure about it you can remove the -i from the rm command.
>
>
How about:

$ rm -i `find /var/spool/mqueue -type f -exec grep "mail\.panteq\.com" 
{} \;`

IMO the for loop is clearer, but I'd use "find"
as a one-liner because I'm more familiar with it.
I have to read the bash manpage practically every
time I write a shellscript...

-- JK




More information about the Ale mailing list