首页 > 系统相关 >linux diff求两个文件的差集

linux diff求两个文件的差集

时间:2023-11-10 15:56:25浏览次数:37  
标签:ip linux 差集 教育网 diff 北京市 txt 昌平区

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

标签:ip,linux,差集,教育网,diff,北京市,txt,昌平区
From: https://www.cnblogs.com/haima/p/17824302.html

相关文章

  • Linux系统常用审计命令
    1、https://blog.51cto.com/u_10401840/5927529Linux中常见日志以及位置/var/log/cron记录了系统定时任务相关的日志/var/log/auth.log记录验证和授权方面的信息/var/log/secure同上,只是系统不同/var/log/btmp登录失败记录使用lastb命令查看/var/log/wtmp登录失成功记录......
  • 《Unix/linux系统编程》教材第6章学习笔记
    |第5章|信号和信号处理信号和中断“中断”是从I/O设备或协处理器发送到CPU的外部请求,它将CPU从正常执行转移到中断处理。与发送给CPU的中断请求一样,“信号”是发送给进程的请求,将进程从正常执行转移到中断处理。在讨论信号和信号处理之前,先来回顾中断的概念和机制,这有助于正确......
  • Linux基础命令(一)
    cd命令 绝对路径:cd/home/admin查看当前目录:pwd返回上一目录:cd..回到admin:cd~返回倒数第二个目录:cd-ls命令:查看目录内容ls:查看普通文件ls-a:查看所有文件(隐藏文件.xxxx)ls-l(ll):查看文件详细信息ls-lh:人性化显示详细列表ls权限drwxr-xr--:d代表文件夹 -代......
  • Linux常用命令-docker
     1、进入容器: dockercontainerexec-it容器id/bin/bash①直接进入容器中的mongodb:sudodockerexec-itmongomongosh②dockerexec-itcontainerName/bin/bash2、容器开机自启动:①docker开机自启动:systemctlenabledocker.servic......
  • linux系统centos7安装docker
    1、Docker官网安装地址https://docs.docker.com/engine/install/centos/#prerequisites2、离线安装下载地址https://download.docker.com/linux/static/stable/x86_64/3、使用yum工具安装如果之前安装需要先卸载sudoyumremovedocker\docker-cl......
  • Linux的一些指令
    这里主要是记录下平时工作中所使用到的Linux系统下的指令 查找指令find-name"*.mk"-o-name"*.bp"|xargsgrep"***"//用于在项目代码中的mk和bp文件查找对应的字段,最后的"***"就是要查找的字段grep-rn***//用于在某个目录下查找关键字***,参数-r是可......
  • Adding Conditional Control to Text-to-Image Diffusion Models
    https://mp.weixin.qq.com/s/iL6YitT7EGP6DnrBehb9MQ1.AddingConditionalControltoText-to-ImageDiffusionModels论文地址:https://arxiv.org/pdf/2302.05543.pdf开源地址:https://github.com/lllyasviel/ControlNet(该项目已有2.4万stars)作者单位:斯坦福大学这......
  • man命令总结linux常用基本命令用法以及查看帮助文档的方法
       Linux中的常见命令1查看系统相关信息命令(1)查看内核版本uname-r(2)显示操作系统发行版本cat/etc/os-release(3)查看当前主机名hostname2查看硬件信息(1)查看CPUlscpucat/proc/cpuinfo(2)查看内存大小free-hcat/proc/meminfo(3)查看硬盘分区情况lsblkcat/proc/partiti......
  • java: 执行Linux命令,获取结果
    packagecom.css.k3.k3xk.action;importjava.io.BufferedReader;importjava.io.InputStreamReader;publicclassMyCommandExecutor{publicstaticStringexecuteCommand(Stringcommand,Stringparameter){Stringresult=null;try{......
  • Linux命令(72)之bunzip2
    linux命令之bunzip21.bunzip2介绍linux命令bunzip2是用来解压缩后缀为".bz2"的文件,等价于bzip2-d2.bunzip2用法bunzip2[参数]filename.bz2bunzip2常用参数参数说明-f强制覆盖已存在的文件-k解压缩后,保留源文件-v显示命令执行详细过程3.实例3.1.解压缩zzz.txt.bz2文件,保留......