[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Need some scripting assistance
- Subject: [ale] Need some scripting assistance
- From: jknapka at kneuro.net (JK)
- Date: Wed, 28 Jun 2006 11:03:05 -0600
- In-reply-to: <[email protected]>
- References: <06d101c69ac2$591c5600$018410ac@win2kpro1> <[email protected]>
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