#!/bin/sh
# www.jb200.com
#
get_week()
{
year=`expr substr $1 1 4`
month=`expr substr $1 5 2`
day=`expr substr $1 7 2`
b=`cal $month $year|wc -l`
b=`expr $b - 1`
week_day=`cal $month $year |
linuxjishu/13830.html target=_blank class=infotextkey>awk '{for(i=1;i<=NF;i++){if($i=='$day'){if (NR=='$b'-1){print i-1}else{print 7-NF+i-1}}}}'`
case `expr $week_day + 1` in
1) week_day_name='Sun' ;;
2) week_day_name='Mon' ;;
3) week_day_name='Tue' ;;
4) week_day_name='Wed' ;;
5) week_day_name='Thu' ;;
6) week_day_name='Fri' ;;
7) week_day_name='Sat' ;;
*) week_day_name= 'wrong date' ;;
esac
echo $week_day_name
}
l_date=`date +%Y%m%d`
kk=`get_week ${l_date}`
echo $kk