zoukankan      html  css  js  c++  java
  • 检测目录文件变更数量及内容变更

    #!/bin/bash
    PATH=/bin:/sbin:/usr/bin:/usr/sbin/:/usr/local/bin:/usr/local/sbin:~/bin
    export PATH
    dir=/home/
    date_one_h=$(date +%Y%m%d%H -d '-1 hours')
    old_file=/root/$(date +%Y%m%d -d '2 day ago')source.file
    source_file=/root/$(date +%Y%m%d)source.file
    new_file=/root/Desktop/$(date +%Y%m%d%H)new.file
    change_content=/root/Desktop/$(date +%Y%m%d%H)diff.file
    old_change_content=/root/Desktop/$(date +%Y%m%d%H -d '2 day ago')diff.file
    if [ -s $source_file ] ;then
    echo the file content alrealy exists!
    else
    #find $dir -print0 | xargs -0 du -sb >$source_file
    ls -lR $dir >$source_file
    echo "$source_file File content has been written!"
    fi
    if [ -s $new_file ] ;then
    echo the $new_file content alrealy exists!
    else
    #find $dir -print0 | xargs -0 du -sb >$new_file
    ls -lR $dir >$new_file
    echo "$new_file File content has been written!"
    fi
    diff_input=$(diff $source_file $new_file)
    if [[ -z $diff_input ]];then
    echo "Nothing change"
    else
    echo "Here is the change"
    echo "$diff_input">$change_content
    fi
    rm -rf $new_file
    rm -rf $old_file
    rm -rf $old_change_content

    改行去放羊
  • 相关阅读:
    触发器
    数据库function和procedure
    java连接数据库
    单例模式
    python入门相关笔记
    ubuntu 系统备份到移动硬盘(tar) 还原到另一台电脑
    大白菜pe 通用pe 安装心得
    18 java 代理模式 (转)
    5 HBase 常用Shell命令
    1、shell 简介
  • 原文地址:https://www.cnblogs.com/musen/p/6444012.html
Copyright © 2011-2022 走看看