我想根据带有校验和的列表查找两个文件夹之间的重复项。
使用一些 shell 脚本(一些 bash、awk 或类似脚本)的解决方案是最好的。
假设对于这两个文件夹我已经生成了两个列表
[FolderA.txt]
file1 abc1
file2 abc1
file3 def5
和
[FolderB.txt]
file4 abc1
file5 mno2
file6 def5
现在我想知道,
- 文件 1 与文件 4 匹配(校验和 abc1 相同)
- 文件 2 与文件 4 匹配(校验和 abc1 相同)
- file3 与 file6 匹配(校验和 def5 相同)
但是,我只想在文件夹之间进行匹配,而不是在一个文件夹内进行匹配。因此,我不希望 file1 和 file2 之间存在匹配。
最佳答案
你可以使用这个:
join -j2 <(sort -k2 FolderA.txt) <(sort -k2 FolderB.txt)
输出:
abc1 file1 file4 abc1 file2 file4 def5 file3 file6
如果您只需要第 2 列和第 3 列,请添加 |切-d“”-f 2-
关于bash - 如何查找两个列表之间的校验和匹配(但不在两个列表内)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27455484/