shell-script-pt
[Top][All Lists]
Advanced

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

Re: [shell-script] Duvidas...


From: SuSE List
Subject: Re: [shell-script] Duvidas...
Date: Mon, 21 Mar 2005 18:19:35 -0300
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Miranda wrote:

>
> [miranda@guitar tmp]$ cat a
> anjo
> meio
> torto
> bateu
> na porta
> da granja do torto
>
> [miranda@guitar tmp]$ grep -n torto a > b
> [miranda@guitar tmp]$ while read linha; do   aux=`echo $linha|cut 
> -d":" -f1`;
> line=`expr $aux - 2`; str=`echo $linha|cut -d":" -f2`; echo "$str 
> ->"`sed -n
> "${line}p" a`; done < b
> torto ->anjo
> da granja do torto ->bateu

Miranda veja como ficou:

msp01:/home/vinicius # mailq > a.txt ; grep -n exam0055 a.txt > b.txt ; 
while read linha; do aux=`echo $linha | cut -d":" -f1`; line=`expr $aux 
- 2`; str=`echo $linha|cut -d":" -f2`; echo "$str -> "`sed -n "${line}p" 
a.txt`; echo "$str -> "`sed -n "${line}p" a.txt` | awk -F" " '{ print 
"Deletando "$3}'; echo " " ; done < b.txt

address@hidden -> EB362268C0 3687 Mon Mar 21 13:57:48 
address@hidden
address@hidden -> E73F62671A 2508 Mon Mar 21 12:58:48 
address@hidden
address@hidden -> EC14826A07 5022 Mon Mar 21 14:06:13 
address@hidden
address@hidden -> E0B8C25BD0 2198 Mon Mar 21 14:19:37 
address@hidden
address@hidden -> E116C25A7A 136142 Mon Mar 21 09:52:11 
address@hidden

adaptando ainda mais, consegui o que eu precisava:

msp01:/home/vinicius # mailq > a.txt ; grep -n exam0055 a.txt > b.txt ; 
while read linha; do aux=`echo $linha | cut -d":" -f1`; line=`expr $aux 
- 2`; str=`echo $linha|cut -d":" -f2`; echo "$str -> "`sed -n "${line}p" 
a.txt` | awk -F" " '{ print $3}' | while read msg_id; do postsuper -d 
$msg_id ; done ;done < b.txt
postsuper: 1A70926669: removed
postsuper: Deleted: 1 message
postsuper: 1C96827271: removed
postsuper: Deleted: 1 message
postsuper: 2C0F524DC1: removed

e mudando mais um pouco:

mailq > a.txt ; grep -n $1 a.txt > b.txt ; while read linha; do 
aux=`echo $linha | cut -d":" -f1`; line=`expr $aux - 2`; str=`echo 
$linha|cut -d":" -f2`; echo "$str -> "`sed -n "${line}p" a.txt` | awk 
-F" " '{ print $3}' | while read msg_id; do postsuper -d $msg_id ; done 
;done < b.txt

7291525FB4    11950 Mon Mar 21 16:36:58  address@hidden
(Host or domain name not found. Name service error for name=ondeo.com.br 
type=MX: Host not found, try again)
                                         address@hidden

msp01:/etc/postfix # ./apaga_spam2.sh address@hidden
postsuper: 7291525FB4: removed
postsuper: Deleted: 1 message
msp01:/etc/postfix/noras #


Ficou muito bom.....valeu a ajuda Miranda!!!

[]s

Vinny



[As partes desta mensagem que não continham texto foram removidas]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]