comm命令:文件的交集与差集

tlc/tk学习笔记 tcl/tk学习笔记,包含tcl/tk的语法,模拟,以及如何与数据库连接等 立即下载

comm用于文件的比较,常用与文件的交、差集合操作。

comm必须使用拍过序的文件作为输入。

例:

文件A.txt:

1

3

5

7

9

文件B.txt:
2

4

7

9

sort A.txt -o A.txt; sort B.txt -o B.txt

-o不输出到stdout,而是到文件中。

comm A.txt B.txt

1
    2
3
    4
5
        7
        9

输出解释:

输出为3列,第一列为只在A中的,第二列为只在B中的,第三列为AB共有的。

要想删除不要的列可以:

-1 不要第一列;

-2 不要第二列;

-3 不要第三列。

一般几列放一起没什么意义。。可以合并到一起,

comm A.txt B.txt -1 -2 | sed 's/^\t//'



C++笔试题整理 目录 1. 笔试题1 1.1 链表反转 1.2 String 2. 笔试题2 2.1 求下面函数的返回值(微软) 2.2 什么是“引用”?申明和使用“引用”要注意哪些问题? 2.3 将“引用”作为函数参数有哪些特点? 2.4 在什么时候需要使用“常引用”?  2.5 将“引用”作为函数返回值类型的格式、好处和需要遵守的规则? 2.6 “引用”与多态的关系? 2.7 “引用”与指针的区别是什么? 2.8 什么时候需要“引用”? 2.9 结构与联合有和区别? 2.10 下面关于. 阅读详情

相关推荐

浅谈MOS管的发热原因和解决办法

解读一下开关管发热原因,解决方案和开关损耗测试。

qq_45508321的博客 1万+

linux 差集,Linux comm命令求出文件的交集、差集

A(1,2,3)和B(3,4,5),A和B的交集是3,A对B的差集是1和2,B对A的差集是4和5,A和B求差的结果是1、2、4、5。在Linux中可以使用comm命令求出这些集。[root@linuxidc tmp]# cat <set1.txt>orange>gold>apple>sliver>steel>iron> eof[root@linuxi...

weixin_36208265的博客 609

均值回归 高频交易_基于布林带的均值回归交易策略

BOLL指标是美国股市分析家约翰·布林根据统计学中的标准差原理设计出来的一种非常简单实用的技术分析指标。一般而言,股价的运动总是围绕某一价值中枢(如均线、成本线等)在一定的范围内变动,布林线指标正是在上述条件的基础上,引进了“股价通道”的概念,其认为股价通道的宽窄随着股价波动幅度的大小而变化,而且股价通道又具有变异性,它会随着股价的变化而自动调整。由于之前大部分交易策略都是选股或者趋势追踪的择时,...

weixin_42528534的博客 1465

[Shell]comm 交集 差集

1. 简介 comm命令可以用于两个文件之间的比较,它有一些选项可以用来调整输出,以便执行交集、求差、以及差集操作。  交集:打印出两个文件所共有的行。  求差:打印出指定文件所包含的且不相同的行。  差集:打印出包含在一个文件中,但不包含在其他指定文件中的行。 2. 语法 comm (选项) (参数) 3. 选项 -

SmartSi 6674

AnyLogic 8.8.3 最新版安装指南:从下载到配置的完整流程(附Java环境设置技巧)

本文提供了AnyLogic 8.8.3最新版从下载到配置的完整安装指南,重点解决了跨平台(Windows、macOS、Linux)部署中的常见问题。核心内容详细讲解了Java开发环境(JDK)的精准配置技巧,包括版本选择、系统环境变量设置与验证,确保为仿真建模工作奠定稳固基础。

efc1234567的博客 781

Unity游戏开发实战:用Flow Field实现RTS百人军团流畅寻路(附完整代码)

本文深入探讨了在Unity中利用流场寻路技术解决RTS游戏大规模单位移动性能瓶颈的实战方案。通过解析从Dijkstra算法生成成本场、积分场到最终向量场的核心原理,并结合分块、缓存及与DOTS/ECS架构集成的优化策略,实现了百人军团的流畅群体寻路。文章提供了完整的代码示例,助力开发者构建高性能的RTS寻路系统。

weixin_28363123的博客 595

简明Linux命令行笔记:comm

比较已经排序的文件 comm [options] file1 file2   comm将逐行比较已经排序的两个文件。显示结果包括3列: 第1列为只在file1中找到的行;第2列为只在file2中找到的行;第3列为两个文件的公用行。   参数 参数file1和file2为comm要比较的文件的路径名。用连字符(-)来替代file1或者file2时,comm将从标准输入读取输入信息  ...

weixin_34088838的博客 229

软件崩溃时Visual Studio中看不到有效的调用堆栈,使用Windbg动态调试去分析定位

当在Visual Studio中遇到软件崩溃且无法查看详细调用堆栈时,可以使用Windbg进行动态调试去分析定位问题。

dvlinker的技术专栏 1万+

流式处理两个文件,求其差集(comm)

背景:有两个数据文件(1.txt和2.txt),1.txt中存储一批垃圾域名,2.txt文件中存有企业上报的域名,现在需要从企业上报域名库中剥离掉垃圾域名。 刚开始使用grep处理,如下: grep -vf ./1.txt ./2.txt &gt; ./result.txt 但是命令执行一会,服务器32G内存全部吃光,一会提示killed 后来想着grep这个命令的内部原理应该是将两个文件...

xiaoheshang1105的专栏 395

Ubuntu开机进入initramfs,解决办法来了!

摘要:Ubuntu系统启动时卡在initramfs界面,表明系统无法正常挂载根文件系统。常见原因包括引导配置错误、文件系统损坏、驱动程序问题和硬件故障。解决方法包括:1)使用fsck修复文件系统;2)通过dmesg排查驱动问题;3)检查硬盘等硬件状态;4)重新安装GRUB引导程序。建议做好系统备份等预防措施,遇到问题时按步骤排查。该问题通常可通过文件系统修复或引导配置重建解决。(148字)

米可的博客! 3426

YOLOv11涨点改进| CVPR 2026 | 全网独家首发、特征融合改进篇| 引入SRFusion 空间细化多级融合,含多种创新融合改进,涨点可直接发论文,适合裂缝图像检测,小目标检测任务高效涨点

🔥本文提出SRFusion空间细化多级融合模块,用于改进YOLOv11网络模型。该模块通过高分辨率特征引导低分辨率语义特征的融合,利用空间注意力机制对上采样后的特征进行加权细化,增强多尺度特征间的空间细节交互。SRFusion模块能够提升模型对目标区域的表达能力,有效改善小目标、密集目标及复杂背景场景下的检测效果,同时保持YOLOv11的高效性与实时检测性能。文章详细介绍了模块结构、实现原理、核心代码及在YOLOv11中的三种配置方法,为模型优化提供了创新解决方案。

Ai缝合怪、助力小伙伴高效发论文 155

Linux系统下,求两个文件列表的差集的方法,comm和grep

假设要1.txt和2.txt,当前的任务是求两者的差集,把差集存储在inter.txt内1)comm:sort 1.txt &gt; 11.txtsort 2.txt &gt; 22.txtcomm -23 11.txt 22.txt &gt; inter.txt该方法需要先对文档排序,排序后再比较,感觉对于大文件,列表包含几百万行的文档,推荐这种方式。2)grep:grep -F -v -f 2...

aimaomi123的博客 1397

Apollo Planning决策规划算法代码详细解析 (1):Scenario选择

本文重点讲解Apollo代码中怎样配置Scenario以及选择当前Scenario,Scenario决策是Apollo规划算法的第一步,本文会对代码进行详细解析,也会梳理整个决策流程,码字不易,喜欢的朋友们麻烦点个关注与赞。 在本文你将学到下面这些内容: 规划器planer的种类; 规划器planer的主要函数及逻辑; 场景管理类ScenarioManager的运行机制; 场景注册方法; 场景决策流程,如何选择当前场景 详细的apollo决策规划代码分析 代码具体过程如下: 1、Scenar

自动驾驶Player的博客 1万+

第二十二章 Linux文件比较,文本文件的交集、差集与求差:comm命令

第二十二章 Linux文件比较,文本文件的交集、差集与求差:comm命令 名词解释 comm 命令 可以用于两个文件之间的比较,它有一些选项可以用来调整输出,以便执行交集、求差、差集操作。 交集:打印两个文件所共有的行 求差:打印出指定文件所包含的其不相同的行。 差集:打印出包含在一个文件中,但不包含在其他指定文件中的行。 语法 comm(选项)(参数) 选项 -1 :不显示在第一个文件出现的...

weixin_33918357的博客 734

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Linux 命令:comm

Linux 命令:comm

闲余知道 1181

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

两个文件内容差异对比,

比较两个单行文件的方法就我知道的而言有4种用diff用grep用comm用uniq[root@hxy~]#echo"`seq5`">file1;catfile1 1 2 3 4 5 [root@hxy~]#echo"`seq27`">file2;catfile2 2 3 4 5 6 71.用diff -c file1多的是"-"file2...

weixin_33709609的博客 2144

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Linux | 比较本文差异

比较两个单行文件的方法就我知道的而言有4种 用diff 用grep 用comm 用uniq [root@hxy ~]# echo "`seq 5`" >file1;cat file1 1 2 3 4 5 [root@hxy ~]# echo "`seq 2 7`" >file2;cat file2 2 3 4 5 6 7 1.用diff -c file1多的是"-"file2多的是"+"按这个就可以过滤出来了 [root@hxy ~]# diff

agonysome的博客 174

linux审计参数comm,comm命令_Linux comm 命令用法详解:两个文件之间的比较

comm命令可以用于两个文件之间的比较,它有一些选项可以用来调整输出,以便执行交集、求差、以及差集操作。交集:打印出两个文件所共有的行。求差:打印出指定文件所包含的且不相同的行。差集:打印出包含在一个文件中,但不包含在其他指定文件中的行。语法comm(选项)(参数)选项-1:不显示在第一个文件出现的内容;-2:不显示在第二个文件中出现的内容;-3:不显示同时在两个文件中都出现的内容。参数文件1:指...

weixin_39915505的博客 506

Linux comm命令

一、comm命令 comm命令可以用于两个文件之间的比较(必须是已经排序的两个文件,可以使用sort命令先进行排序),它有一些选项可以用来调整输出,以便执行交集、求差、以及差集操作。 交集:打印出两个文件所共有的行。 求差:打印出指定文件所包含的且不相同的行。 差集:打印出包含在一个文件中,但不包含在其他指定文件中的行。 1.1 语法 comm(选项)(参数) 1.2 选项 选项...

书香水墨 3428

linux文本排序、交集、差集,查找并删除重复文件脚本、comm命令

comm 命令comm命令可用于两个文件之间的比较。通过参数调整输出,可以执行交集、求差以及差集操作。- 交集:打印出两个文件所有共同的行。- 求差:打印出指定文件所包含的互不相同的那些行。- 差集:打印出包含在文件A中,但不包含在其他指定文件中的那些行。 需要注意的是,comm必须使用经过排序的文件作为输入。在linux中可以使用sort命令实现排序。 comm实战建立两个文本文件输入以下内容:

GZX的专栏 4676

linux两个文件取交集、并集、差集

如何得到两个文件的交集、并集和差集? 交集:两个文件中都出现的行 并集:两个文件中的所有行加起来,去掉重复 差集:在一个文件中存在,而在另一个文件中不存在。 比如以下两个文件: a.txt aaa bbb ccc 111 222 b.txt ccc ddd eee 111 333 结果: a.txt和b.txt的交集: ccc 111 a.txt和b.txt的并集: 111 222 333 aaa bbb ccc ddd eee a.txt中存在b.txt中不存在: 222 aaa bbb b.txt中存在

Kenina_Xie的博客 2745

LINUX Shell 下求两个文件交集和差集的办法

假设两个文件FILE1和FILE2用集合A和B表示,FILE1内容如下:abceda FILE2内容如下:cdac基本上有两个方法,一个是comm命令,一个是grep命令。分别介绍如下: comm命令, Compare sorted files FILE1 and FILE2 line by line. With  no op

autofei的专栏 7万+

求两文件数据的交集c语言,两个数据文件求交集、差集

问题描述对于两个同处在一个集群的hive表,进行文件或者数据的对比是非常方便的,直接写个关联查询就可以搞定。然而有时候,一个表在MySql里,一个在Hive里,或者是两个表在不同的MySql库下,而我们对两份数据只做临时的比对,把数据抽到集群再进行计算,显然有些麻烦。通常的做法是,我们把两个不同源的数据抽出需要的字段,导出到两个文本文件里,然后通过shell命令或者excel等工具处理一下。com...

weixin_31755479的博客 657

linux求两个文件的差集,Linux 求文件交集 差集等

使用comm命令假设两个文件FILE1和FILE2用集合A和B表示,FILE1内容如下:abcedaFILE2内容如下:cdac基本上有两个方法,一个是comm命令,一个是grep命令。分别介绍如下:comm命令, Compare sorted files FILE1 and FILE2 line by line. With no options, produce three-column o...

weixin_39821874的博客 475

Linux文件比较操作---文本文件的交集、差集与求差

为什么80%的码农都做不了架构师?>>> ...

weixin_34019929的博客 456

comm比较两个文件的异同

题外话:说到比较文件,过来人都用过Beyond Compare,老版本时候,我们只能右键选中用于比较的文件,再选中被比较文件,对比。 如今他有了丰富的界面,支持linux上比较文件。 干什么用的?svn管理不善的时候,版本控制做的不好的时候,你就会期望他了。这都是经验- -!  回到正题:在shell中,也有个这么个命令---comm。 comm可用于两个文件之间的比较。可以用于文件的比

cws1214的专栏 4041
上一篇: 生成任意大小文件
下一篇: crontab命令实例学习
国服第l帅
博客等级 码龄12年 26粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址