trying to do a precise query of log files (i.e. all the bounces in the last 30 days).
I seam to be missing 2 factors, I don't think stdin will pull zcat info and I think there is also an error passing the variable to awk.
home # lastDate=$(date -d "last month" 2>&1 {$1, $2, $3}) | cat /var/log/messages | zcat /var/log/messages-* | awk '$0>=from&&$0<=to' from='{ print date +"%m-%d"}' to=$lastDate '{print to}' | grep -i reject
awk: fatal: cannot open file `{print to}' for reading (No such file or directory)
where broke:
lastDate=$(date -d "last month" 2>&1 {$1, $2, $3})|awk '{print lastDate}'
no error, no output
date -d "last month" Fri Jul 26 07:13:40 UTC 2013