我有一个完整的专有格式二进制文件的文件夹,我必须使用笨拙的软件导出到文本文件,最后我最终得到一个文件夹对应的文件夹:
myfile1.bin
myfile1.bin.txt
myfile2.bin
myfile2.bin.txt
myfile3.bin
myfile3.bin.txt
我不断将新的bin文件推送到服务器,以便myfile3.bin
的文件大小可能已更改,我现在有了一个新的myfile4.bin
。所以我需要定期检查bin
文件中哪些txt
文件已更改(大小/时间戳)以及哪些bin
文件没有txt
文件并将其写入我可以使用软件加载的changed.txt文件来转换新文件。
我想我必须保留当前文件夹中的文件列表(包括时间戳和大小),并在10分钟内将文件夹内容与保存的信息进行比较,以查看更改的内容。
非常感谢任何想法和帮助!
答案 0 :(得分:1)
请检查以下是否有帮助:
#!/bin/bash
while [ 1 ]
do
ls -ltr /dir_to/Monitor > out.txt # you can try ls -1l as well, depending upon the requirement
sleep 600
ls -ltr /dir_to/Monitor > out1.txt
if diff out.txt out1.txt > diff.txt; then
echo "Not Changed"
else
echo "Changed" # diff is changed
cp diff.txt diff_$(date +%s).txt #Copy the diff to a different file.
fi
done