使用 shell 脚本比较 2 个文件
我试图找到知道两个文件是否相同的方法,并发现了这篇文章...
我在第一个答案中使用了代码,但我认为它不起作用,或者至少我无法让它正常工作......
我什至尝试制作一个文件的副本和比较两者(副本和原始),我仍然得到答案,就好像它们不同一样,而实际上它们不应该不同。
有人可以帮我一下,或者解释一下发生了什么吗?
非常感谢;
佩克斯
I was trying to find the way for knowing if two files are the same, and found this post...
Parsing result of Diff in Shell Script
I used the code in the first answer, but i think it's not working or at least i cant get it to work properly...
I even tried to make a copy of a file and compare both (copy and original), and i still get the answer as if they were different, when they shouldn't be.
Could someone give me a hand, or explain what's happening?
Thanks so much;
peixe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否试图比较两个文件是否具有相同的内容,或者您是否试图查找它们是否是同一文件(两个硬链接)?
如果您只是比较两个文件,请尝试:
或
以查看假定的差异。
您还可以尝试
md5sum
:如果两个文件返回相同的校验和,则它们是相同的。
Are you trying to compare if two files have the same content, or are you trying to find if they are the same file (two hard links)?
If you are just comparing two files, then try:
or
in order to see the supposed differences.
You can also try
md5sum
:If both files return same checksum, then they are identical.
comm
是一个比较文件的有用工具。comm
is a useful tool for comparing files.