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}}'


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章