Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 将二进制文件与导出的文本文件进行比较,找出自上次导出以来哪些二进制文件已更改或是下一个_Linux_Bash_File_Shell_Batch File - Fatal编程技术网

Linux 将二进制文件与导出的文本文件进行比较,找出自上次导出以来哪些二进制文件已更改或是下一个

Linux 将二进制文件与导出的文本文件进行比较,找出自上次导出以来哪些二进制文件已更改或是下一个,linux,bash,file,shell,batch-file,Linux,Bash,File,Shell,Batch File,我有一个文件夹,里面装满了专有格式的二进制文件,我必须使用一个笨拙的软件将其导出为文本文件,最后我得到了一个文件夹,里面装满了文件对: myfile1.bin myfile1.bin.txt myfile2.bin myfile2.bin.txt myfile3.bin myfile3.bin.txt 我不断地将新的bin文件推送到服务器,以便myfile3.bin的文件大小可能已经更改,现在我有了一个新的myfile4.bin。因此,我需要定期检查哪些bin文件已从txt文件更改(大小/时间

我有一个文件夹,里面装满了专有格式的二进制文件,我必须使用一个笨拙的软件将其导出为文本文件,最后我得到了一个文件夹,里面装满了文件对:

myfile1.bin
myfile1.bin.txt
myfile2.bin
myfile2.bin.txt
myfile3.bin
myfile3.bin.txt
我不断地将新的bin文件推送到服务器,以便
myfile3.bin
的文件大小可能已经更改,现在我有了一个新的
myfile4.bin
。因此,我需要定期检查哪些
bin
文件已从
txt
文件更改(大小/时间戳),哪些
bin
文件没有
txt
文件,并将其写入更改后的.txt文件中,我可以使用软件加载该文件以转换新文件

我想我必须保留文件夹中当前文件的列表(包括时间戳和大小),并在10分钟内将文件夹内容与保存的信息进行比较,以查看更改的内容


非常感谢您的任何想法和帮助

请检查以下内容是否有帮助:

#!/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 

知道为什么会出现否决票会很有帮助,这样我就可以避免在问下一个问题时犯同样的错误,或者相应地修改这个问题。。我想,与其成对比较所有文件,不如只记下上次转换的时间戳,转换每个较新的文件,或者干脆将转换后的文件移到另一个文件夹中。@gletscher请告诉我,如果需要在脚本中进行一些扩展。