Daily grep on a log file

Hi,
I would like to execute a daily grep like:
grep 2010-09-06 statistics.log|grep API > /var/tmp/stat20100906_sp.txt

On date e.g. 2010-09-07 run a grep on yesterday's date, from the result grep the word "API" put all in /var/tmp
Would like to have a script configured in the crontab, running a grep on "yesterday's" date and put in in /var/tmp.

Today I execute this manually each day...:cool:

P.S. O/S = Solaris (bash)

If your date command doesn't support -d "yesterday", then read it:
http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html

Otherwise, test below script and put in cronjob.

d1=$(date -d "yesterday" +%Y-%m-%d)
d2=$(date -d "yesterday" +%Y%m%d)
grep $d1 statistics.log|grep API > /var/tmp/stat${d2}_sp.txt

-d "yesterday" not supported...

Tried the script, -d is not supported.:frowning:
Any idea?:confused:

perl -e '@T=localtime(time-86400);printf("20%02d-%02d-%02d\n",($T[5]+1900)%100,$T[4]+1,$T[3])'