#!/bin/ksh get_one_day_before_specified_date() { # get the command line input (date,month & year) month=$1 year=$2 # if it is the first month of the year if [ $month -eq 01 ] then # make the month as 12 month=12 # deduct the year by one year=`expr $year - 1` else # deduct the month by one month=`expr $month - 1` fi typeset -Z2 month=${month} echo $year$month } if [ $# -ne 2 ] then m=`date +%m` y=`date +%Y` else m=$1 y=$2 fi LAST_Month=`get_one_day_before_specified_date $m $y` now_Month=`date "+%Y%m"` if swlist -l fileset -a install_date|awk '{print $2}'|grep 2017|sort -nr|uniq|egrep "$LAST_Month|$now_Month" >/dev/null 2>&1 then echo "OK" else echo "NOK" fi