My scripting talent is sadly failing...
Glenn Steen
glenn.steen at gmail.com
Wed Jan 24 14:44:05 CET 2007
On 24/01/07, Tom G. Christensen <tgc at statsbiblioteket.dk> wrote:
> Nigel Kendrick wrote:
> > Hi Folks,
> >
> > I have put together the following one-liner to re-submit all emails sent to
> > me from an archive folder - it works EXCEPT that the 'echo/cut' command is
> > not removing the file extension from the file name and so the emails are not
> > processed in the queue. Would someone kindly have a look and educate me!!
> >
> > grep -l 'To: <nigel.kendrick' * | xargs -t -i bash -c "chmod 700 {} ; cp {}
> > /var/spool/postfix/hold/`echo {} | cut -d . -f 1` "
> >
> I often find that using a simple for loop is much more straightforward
> than fiddling with xargs.
> Like this:
> for i in $(grep -l 'To: <nigel.kendrick' *); do fnam=$(echo $i | cut -d.
> -f1); chmod 700 $i; cp $i /var/spool/postfix/hold/$fnam); done
>
Not to mention that it removes the problem here by not needing that
"second bash", and the whole "which bach expands what" problem:-).
As to for efficiency compared to xargs here is perhaps even better,
since it'd preclude one fork/file... If that matters, which it likely
don't:-).
--
-- Glenn
email: glenn < dot > steen < at > gmail < dot > com
work: glenn < dot > steen < at > ap1 < dot > se
More information about the MailScanner
mailing list