【发布时间】:2021-10-29 18:28:09
【问题描述】:
我在一个名为 rpmlist.txt 的文件中有一个 rpm 文件列表,我必须将其与另一个列表 newlist.txt 进行比较,看看它们在 Bash 中是否相同。例如,这是我的要求:
rpmlist.txt 中的文件
bash-4.4-9.10.1_x86_64
binutils-2.32-7.8.1_x86_64
bison-3.0.4-1.268_x86_64
newlist.txt 中的文件
bash-5.4-9.10.1_x86_64
binutils-2.32-7.8.1_x86_64
bison-6.0.4-1.268_x86_64
并打印它们是否匹配。任何帮助将不胜感激
【问题讨论】:
-
diff -y file1 file2,comm -12 <(sort file1) <(sort file2),grep -f file1 file2... -
行的顺序重要吗?
-
不,订单可以是任何东西。只需 list1 必须检查 list2 上是否有任何匹配项。
-
什么是list2? newlist.txt 可以包含不在 rpmlist.txt 中的文件吗? rpmlist.txt 可以包含不在 newlist.txt 中的文件吗?
-
您使用“相等”等词的方式是模棱两可的。如果您在问题中添加“匹配”和“不匹配”的示例,将会有所帮助。
1:abc = 2:abc?1:abc = 2:acb?1:abc = 2:abcd?1:abc = 2:bcd?1:abc = 2:ab?等