通过校验和查找目录中的已修改文件

时间:2019-07-16 05:21:08

标签: bash last-modified data-integrity

我创建了两个文件,一个带有文件夹中所有单个文件的校验和,另一个带有一些修改(添加,删除和修改)后相同文件夹中所有文件的单个校验和。我需要找出在第二次运行checksum命令期间已修改的文件。

我尝试使用comm命令。

comm -23 firstfile secondfile | awk '{print $2}' |sort > added.txt
comm -23 secondfile firstfile | awk '{print $2}' |sort > deleted.txt

我试图找到一种方法来查找已被修改的文件。

1 个答案:

答案 0 :(得分:1)

md5sum *.txt > sum1

md5sum *.txt > sum2

diff sum1 sum2

校验和不是监视更改的好方法,因为它们仅限于校验和的差异。

如果要处理文件系统事件,可以使用 inotify http://man7.org/linux/man-pages/man7/inotify.7.html

如果您只想观看事件,则可以使用 iwatch http://iwatch.sourceforge.net/documentation.html)来检测目录中的更改。另一种替代方法是 watchman ,它是由法制书(https://www.tecmint.com/watchman-monitor-file-changes-in-linux/

开发的
相关问题