Shell小脚本示例

来源:互联网 发布:备份windows激活信息 编辑:程序博客网 时间:2024/03/29 03:36

 

YY=`date +%Y`

MM=`date +%m`

 

if [ "$MM" == "01" ]; then 

    MM=12

    YY=`expr $YY - 1`

else

    MM=`expr $MM - 1`

    #对于经过计算后的一位数的月份,前面补0

    if [ $MM < 10 ]; then 

        MM="0$MM"

    fi

fi

 

file=$YY$MM.xml

echo "info: searching $file ..."

 

cd /portal/shell/billInfo/bill/WHbillXMLView

if [ ! -f "$file" ]; then 

    echo "error: the source bill file $file does not exist"  

else

    dir="/portal/applications/hkweb/WEB-INF/billfile/3Gbill/$YY$MM"

    if [ ! -d $dir ]; then 

        echo "info: now reading $file" 

        cd /portal/shell/billInfo

        java -cp saxon.jar:saxon-jdom.jar:bill.jar TestdirectSubxml

        echo "info: $YY$MM is successfully accomplished" 

    else

        echo "error: $YY$MM is accomplished last time!"

    fi

fi