shell脚本实例-跟踪网站日常变动

#!/usr/bin/bash

#用途:跟踪网页是否有更新

if [ $# -ne 1 ];then

echo -e "$Usage $0 URl "

exit

fi

first_time=0 #非第一次运行这个脚本

if [ ! -e "last.html" ] ;then

first_time=1

fi

curl $1 -o recent.html #下载静态页面

if [ $first_time -ne 1 ];then

change=$(diff -u last.html recent.html) #diff 是对比两个文件是否发生了变话

if [ -n $change];then

echo -e "Changes: "

echo "$change"

else

echo -e " Website has no change..."

fi

else

echo "[First run] ......."

fi

作者简介: 
陈志珂(头条号:强扭的瓜不好吃)目前就职于中国最大的安卓应用软件公司,任高级工程师现在公司任php开发工程师,python开发工程师,高级运维工程师,公众号“铅笔学园”运维内容合作作者之一。
铅笔学园:IT资源分享|知识分享,做初级程序员的指明灯

原文地址:https://www.cnblogs.com/qianbixueyuan/p/9452581.html