#!/bin/rc argv0=$0 fn usage { echo usage: $argv0 '[-ds datestart] [-de dateend] searchstr' >[1=2] exit 'usage' } datestart=() dateend=() while(~ $1 -*){ switch($1){ case -ds datestart=$2 shift case -de dateend=$2 shift case * usage } shift } if(! ~ $#* 1) usage searchstr=$"1 ramfs mkdir /tmp/mails for(f in `{ls | sort -rn}) { date = `{echo $f | sed 's/\.00$//'} if(~ $#datestart 0 || test $date -ge $datestart >/dev/null >[2=1]) { if(~ $#dateend 0 || test $date -le $dateend >/dev/null >[2=1]) { if(grep -i $"searchstr <$"f >/dev/null) { aux/stub /tmp/mails/^$f bind $f /tmp/mails/^$f } } } }