如何检查是否字符串列表是两个单独的文件present [英] How to check if a list of strings are present in two separate files

查看:101
本文介绍了如何检查是否字符串列表是两个单独的文件present的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文件,​​文件A是IP地址的列表与在同一行对应的MAC地址。 文件B是唯一的MAC地址的列表。我需要比较两个文件并列出从文件中的行不都在文件B.发现MAC地址

I have two files, "File A" is a list of IP Addresses with corresponding MAC addresses on the same line. "File B" is a list of only MAC addresses. I need to compare the two files and list the lines from File A that do not have MAC addresses found in File B.

文件:

172.0.0.1 AA:BB:CC:DD:EE:01
172.0.0.2 AA:BB:CC:DD:EE:02
172.0.0.3 AA:BB:CC:DD:EE:03

文件B:

AA:BB:CC:DD:EE:01
AA:BB:CC:DD:EE:02

所以输出应该是:

So the output should be:

172.0.0.3 AA:BB:CC:DD:EE:03

我要寻找一个在SED时,awk,grep的,Python或真的什么解决方案,给我我想要的文件。

I am looking for solutions in sed, awk, grep, python or really anything that give me the file I want.

推荐答案

请问您输入真有每行开始的美元符号,或者是你的问题的格式怪癖?如果你能摆脱美元的迹象,那么你可以使用这样的:

Does your input really have a dollar sign at the start of every line, or is that a formatting quirk of your question? If you can get rid of the dollar signs, then you can use this:

fgrep -v -f fileb filea

这篇关于如何检查是否字符串列表是两个单独的文件present的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆