FreeBSD
[root@mx1 ~/crontab]# date +%Y-%m-%d #当前时间
2011-08-02
[root@mx1 ~/crontab]# a=`date -v -1d +%d` #赋值变量
[root@mx1 ~/crontab]# echo $a #查看变量的值
01
[root@mx1 ~/crontab]# if [ $a == "01" ];then echo "right"; fi #以字符的形式判断
right
[root@mx1 ~/crontab]# if [ $a -eq 1 ];then echo "right"; fi #以数字的形式判断
right
Linux
[root@archive2 sysadmin]# b=`date -d next-day +%d`
[root@archive2 sysadmin]# echo $b
03
[root@archive2 sysadmin]# if [ $b == "01" ];then echo "False"; fi
[root@archive2 sysadmin]# if [ $b -eq 1 ];then echo "False"; fi
[root@archive2 sysadmin]# if [ $b -eq 3 ];then echo "False"; fi
False
[root@archive2 sysadmin]# if [ $b == "03" ];then echo "False"; fi
False