Assuming you have a version of date that supports +%s and -d (GNU date seems to do this), then this should work in either kshell or bash:
# returns success if date passed in is more than three months in the past
# assumes the date is in the form yyyy-mm-dd mm and dd can be single digits.
function is_old
{
if [[ -z $_now ]] # "static" values set on first call
then
_dim=( 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 ) # days in months; yes -- 15 months!!
_now=$(date +%s )
_m=$(date +%Y%m ) # current month
_y=${_m:0:4}
if (( _y % 4 == 0 )) # works until 2100, so keep it simple
then
_dim[4]=29 # leap year this year
fi
(( _m = ${_m:4:2} + 2 )) # proper index into dim
fi
typeset tdate=$(date -d $1 +%s ) # convert date to check into seconds past epoch
typeset cutoff=$(( _now - (86400 * ( (_dim[_m-1] + _dim[_m-2] + _dim[_m-3]))) ))
return $(( tdate > cutoff ))
}
# simple loop to read date from stdin
while read d
do
if is_old $d
then
echo "old: $d"
else
echo "not: $d"
fi
done
If you are not as particular about what "three months" means, and could accept calling something old if it is simply more than 90 days old, then you could use the function below --
This is not a message one would expect, because date would normally report something, not the shell itself and +%s is not a command in this cases but a parameter. So why does your shell see this a command?
What is the exact command that you typed?
Are you running date '+%s' locally on your dev box??