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

    改行去放羊
  • 相关阅读:
    实验报告2
    实验三 网络欺骗技术
    实验3
    心理魔术
    实验报告
    实验4
    实验5
    实验四恶意代码
    网络对抗技术 实验一
    实验二
  • 原文地址:https://www.cnblogs.com/musen/p/6444012.html
Copyright © 2011-2022 走看看