linux diff求两个文件的差集
awk
从文本中过滤出需要的ip
queryId_20231109214653_ipBatchQueryResult.json
{"id":0,"ip":"121.204.216.130","type":1,"domain":"","agreement":"","mode":"","postalCode":"102200","longitude":"116.301434","latitude":"40.089029","xCoordinate":"","yCoordinate":"","timeZone":"UTC+8","organization":"中国教育网","ipOperator":"中国教育网","asn":"4538","country":"中国","continent":"亚洲","province":"北京市","city":"北京市","district":"昌平区","scene":"企业专线","geoGraphyPosition":"北京市-北京市-昌平区","ipPositionMode":"算法定位","address":"北京市-北京市-昌平区"}
{"id":0,"ip":"121.204.216.131","type":1,"domain":"","agreement":"","mode":"","postalCode":"102200","longitude":"116.301434","latitude":"40.089029","xCoordinate":"","yCoordinate":"","timeZone":"UTC+8","organization":"中国教育网","ipOperator":"中国教育网","asn":"4538","country":"中国","continent":"亚洲","province":"北京市","city":"北京市","district":"昌平区","scene":"企业专线","geoGraphyPosition":"北京市-北京市-昌平区","ipPositionMode":"算法定位","address":"北京市-北京市-昌平区"}
过滤数据
$ tail -n 1 queryId_20231109214653_ipBatchQueryResult.json | awk -F '{"id":0,"ip":"' '{print $2}' | awk -F '","type' '{print $1}'
152.136.16.211
diff
求两个文件的差集
sourceIP.txt
中有,resultIP.txt
中没有的数据
sourceIP.txt
acb
dd
111
ccc
222
333
444
555
666
777
resultIP.txt
111
222
333
000
求差集
$ diff <(grep "" sourceIP.txt) <(grep "" resultIP.txt) | grep "< *"| awk -F "< " '{print $2}'
acb
dd
444
555
666
777
[Haima的博客]
http://www.cnblogs.com/haima/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
2021-11-10 python 操作xls
2021-11-10 python—CSV的读写
2021-11-10 在python中安装包出现Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
2020-11-10 docker 安装 kafka+zookeeper,golang操作kafka
2020-11-10 VMware安装Centos7超详细过程(图文)
2019-11-10 安装echo框架
2019-11-10 gin框架博客实战教程2019web页面开发go语言实战博客开发