问题标签 [comm]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
58 浏览

java - Java 中的 comm 实现(comm - 选择或拒绝两个文件共有的行)

我有 2 个大文件。其中一个包含原始数据库,其中事务按字母顺序逐行排序,第二个包含增量数据库,事务也按字母顺序排序。我需要的是获取两个文件中的所有常见事务。在 Java 中是否有一种快速且优化的方式来执行此操作?谢谢。

0 投票
1 回答
80 浏览

command-line - 在命令行中保留具有特定相同列的文本内容

基本上我尝试像这样在命令行中操作文件:

现在我想保持 file1 的内容在 file2 中具有相同的列号,所以输出应该是:

我用过comm -3 file1 file2,但它不起作用。然后我尝试了 sed 但也没有用。还有其他方便的工具吗?

0 投票
1 回答
1416 浏览

diff - BASH:比较多个文件时的通讯(或类似)

我有以下问题:我想比较包含这样一个列表的 8 个文件的内容

使用comm Sample1.txt Sample 2.txt我可以有这样的东西

意思是在第一列中我有一些只与第一个样本有关的东西,第二列是只与第二个样本相关的东西,第三列是共同点。

我想做同样的事情,但有 8 个文件(示例)。使用 diff 是不可能的,但最后我想拥有

有没有机会用 bash 做到这一点?是否有像 diff 这样的命令允许搜索两个以上文件的差异?

谢谢大家...我知道这是一个具有挑战性的问题

法比奥

0 投票
2 回答
1099 浏览

linux - How to display line numbers when comparing files with linux "comm" tool

I would like to diff two very large files (multi-GB), using linux command line tools, and see the line numbers of the differences. The order of the data matters.

I am running on a Linux machine and the standard diff tool gives me the "memory exhausted" error. -H had no effect.

In my application, I only need to stream the diff results. That is, I just want to visually look at the first few differences, I don't need to inspect the entire file. If there are differences, a quick glance will tell me what is wrong.

'comm' seems well suited to this, but it does not display line numbers of the differences.

In general, my multi-GB files only have a few hundred lines that are different, the rest of the file is the same.

Is there a way to get comm to dump the line number? Or a way to make diff run without loading the entire file into memory? (like cutting the input files into 1k blocks, without actually creating a million 1k-files in my filesystem and cluttering everything up)?

0 投票
1 回答
175 浏览

php - com,awk 替代 php

我有 2 个文件:
images1.txt
--file1
--file2
--file5
--file6
--file7
images2.txt
--file1
--file5
--file6

我需要创建具有预期结果的文件 images_to_delete.txt:
images_to_delete.txt
--file2
--file7

我知道我可以用 bash 使用命令来做到这一点:

有没有可能在不使用 shell_exec 的情况下在 PHP 中执行此操作?

谢谢你。

0 投票
2 回答
1120 浏览

sorting - 在两个文本文件中查找相同的单词

我有两个文本文件,每个文件包含超过 50 000 行。我需要在两个文本文件中找到相同的单词。我尝试了 COMM 命令,但得到的答案是“文件 2 未按排序顺序”。我试图通过命令 SORT 对文件进行排序,但它不起作用。我在 Windows 中工作。它不必在命令行中解决。它可以在一些程序或其他东西中解决。谢谢你的每一个想法。

0 投票
2 回答
97 浏览

bash - 从 comm 中获取一列输出而不丢失空行

我正在尝试为每个用户收集软件安装列表。我在 file1.txt 中有完整的用户列表,在 file2.txt 中有安装软件的用户列表。我想以仅在 file1.txt 或 file1.txt 和 file2.txt 中的行结束,但包括空白行。所以:

文件1.txt

文件2.txt

我可以通过 中途到达那里comm -2 file1.txt file2.txt,这给了我:

我希望输出为:

用“Y”替换实际输出行的奖励积分:

但是找不到用cutor保留空行的方法awk

0 投票
0 回答
318 浏览

linux - 在 Solaris(或 Linux)上的两个文件中查找非 SIMILAR 行

我试图比较 Solaris 盒子上的 2 个文件,只看到不相似的行。我知道我可以使用下面给出的命令来查找不完全匹配的行,但这对于我尝试做的事情来说还不够好。

comm -12 <(sort FILE1.txt | uniq) <(sort FILE2.txt | uniq) > diff.txt

出于这个问题的目的,我将 simlar 定义为大约 80% 的时间具有相同的字符,但完全忽略不同的位置(因为不同的部分也可能在长度上有所不同)。可以假设不同的位置出现在线路中大致相同的点。换句话说,一旦我们找到不同的位置,我们就必须弄清楚何时再次开始比较。

我知道这是一个很难解决的问题,并将感谢任何帮助/想法。

编辑:

示例输入 1:

示例输入 2:

示例输出:

我也意识到,如果文件没有一次全部读入内存,那将是理想的,因为它们可能接近 100 个演出。由于这种需要,也许 perl 会比 bash 更好。

0 投票
4 回答
2098 浏览

bash - Bash 脚本比较 2 个文件的值并打印一个文件的输出值

我有两个这样的文件;

文件 1
114.4.21.198,cl_id=1J3W7P7H0S3L6g85900g736h6_101ps 114.4.21.205,cl_id=1O3M7A7Q0S3C6h85902g7b3h7_101pf 114.4.21.205,cl_id=1W3C7Z7W0U3J6795197g177j9_117p1 114.4.21.213,cl_id=1I3A7J7N0M3W6e950i7g2g2i0_1020h

文件2
cl_id=1B3O7M6C8T4O1b559i2g930m0_1165d
cl_id=1X3J7M6J0W5S9535180h90302_101p5
cl_id=1G3D7X6V6A7R81356e3g527m9_101nl
cl_id=1L3J7R7O0F0L74954h2g495h8_117qk
cl_id=1L3J7R7O0F0L74954h2g495h8_117qk
cl_id=1J3W7P7H0S3L6g85900g736h6_101ps
cl_id=1W3C7Z7W0U3J6795197g177j9_117p1
cl_id=1I3A7J7N0M3W6e950i7g2g2i0_1020h
cl_id=1Q3Y7Q7J0M3E62953e5g3g5k0_117p6

我想比较 file1 上存在但 file2 上不存在的 cl_id 值,并打印出 file1 中的第一个值(IP 地址)。

应该是这样的

114.4.21.198
114.4.21.205
114.4.21.205
114.4.21.213
114.4.23.70
114.4.21.201
114.4.21.211 120.172.168.36

我试过 awk、grep diff、comm。但没有什么能接近。请告诉正确的命令来执行此操作。

谢谢

0 投票
1 回答
72 浏览

perl - Apply command in terminal to all possible file combinations in a directory

Have a quick question:

I want to use one/either of the following scripts to determine the common lines between all the combinations of different files in a directory (the directory has 25 files).

or

However, I want to use the command on all of the possible bi-combinations of files (in my case that would be 300 unique file combinations).

Is there a way to modify this command line script to account for all possible combinations at the same time?

Thanks in advance for any help.