shell 相关

# cat fbcheck.sh

#!/bin/bash


DATE=`date -d today +"%Y-%m-%d %H:%M:%S"`

OLDFILE=/tmp/oldfile

NEWFILE=/tmp/newfile


read -p "Please input the Old URL:" OLDURL

read -p "Please input the New URL:" NEWURL


cd /tmp

curl ${OLDURL} >${OLDFILE}

curl ${NEWURL} >${NEWFILE} #因为回显出乱的东西,所以干脆直接写入文件

cat ${OLDFILE} | grep 'RELEASE' | awk -F / '{print $(NF-1)}' | awk -F - '{$NF=unll;print}' |awk '{if (NF==3)print $1$2,$3;else print $1,$2}' |sed 's/\.//g' >tmpold

过滤关键字,取倒数第2字段,整理输出,由于字段不一,整理再输出

cat ${NEWFILE} | grep 'RELEASE' | awk -F / '{print $(NF-1)}' | awk -F - '{$NF="";print}' | awk '{if (NF==3)print $1$2,$3;else print $1,$2}' |sed 's/\.//g' >tmpnew

COUNT1=`cat /tmp/tmpold | wc -l`

COUNT2=`cat /tmp/tmpold | wc -l`

检查行数是否正常

if [ ${COUNT1} -eq ${COUNT2} ] && [ ${COUNT1} -eq 11 ]

   then

      echo "RUL data acquisition success. Start analysis ..."

   else

      echo "RUL data acquisition failure. Pls check !"

fi

echo "The version of the package has a problem, please correct !!!"

一起打印做最后对比,并输出结果。(无输出表示正常)

paste /tmp/tmpold /tmp/tmpnew |awk '{if ( $1 == $3 && $2 > $4 ){print}}'


你可能感兴趣的:(shell)