1 #!/bin/bash
  2 
  3 date #显示当前日期
  4 
  5 year=$(date +%Y)
  6 a=$(date +%m)
  7 b=$(date +%e)
  8 #b=8
  9 echo "please enter you birthday months:"#输入你的生日的月份
 10 read month
 11 if [ $month -gt 12 ]
 12 then
 13         echo "input error"
 14 fi
 15 
 16 echo "please enter you birthday days:"#输入你生日的天数
 17 read day
 18 if [ $day -gt 31 ]
 19 then
 20         echo "input error"
 21 fi
 22 
 23 if [ $month -gt $a ]    #如果生日月份比当前月份大
 24 then
 25         tt=$[$month - $a]
 26         for i in `seq 1 $tt`
 27         do
 28                 t=$(cal $a $year|wc -w)
 29                 m=$[$t - 9]
 30                 a=$[$a + 1]
 31                 sum=$[$sum + $m]
 32         done
 33         echo "From my birthday days:$[$sum - $b +$day]"
 34 else                    #如果生日月份比当前月份小
 35         for j in `seq $a 12`
 36         do
 37                 t=$[$(cal $a $year|wc -w) - 9]
 38                 sum2=$[$sum2 + $t]
 39                 a=$[$a + 1]
 40         done
 41         year=$[$year + 1]
 42         for i in `seq 1 $[$month - 1]`
 43         do
 44                 m=$[$(cal $i $year|wc -w) - 9]
 45                 sum1=$[$sum1 + $m]
 46         done
 47         echo "From your birthday days:$[$sum1 + $sum2 + $day -$b]"
 48 fi