#!/bin/csh -f # put mails in the folders set sub=(test1 test2) set fol=(t1 t2) set to=(group2 group3) set folto=(t2 t3) inc cd ~/Mail/inbox set i=1 while(${i} <= 100) if(!(-e ${i})) goto tryagain rm -f temp.sub1 temp.to1 head -30 ${i} |grep Subject > temp.sub1 set j=1 while (${j} <= ${#sub}) rm -f temp.sub2 cat temp.sub1 |grep ${sub[$j]} > temp.sub2 if(!(-z temp.sub2)) then refile +$fol[$j] ${i} goto tryagain endif @ j = ${j} + 1 end head -30 ${i} |grep To > temp.to1 set j=1 while (${j} <= ${#to}) rm -f temp.to2 cat temp.to1 |grep ${to[$j]} > temp.to2 if(!(-z temp.to2)) then refile +$folto[$j] ${i} goto tryagain endif @ j = ${j} + 1 end tryagain: @ i = ${i} + 1 end rm -f temp.sub1 temp.to1 temp.sub2 temp.to2