标签: comm

两个文件之间的公共行

我在我的终端上运行了以下代码。

LC_ALL=C && grep -F -f  genename2.txt hg38.hgnc.bed > hg38.hgnc.goi.bed
Run Code Online (Sandbox Code Playgroud)

这并没有给我两个文件之间的公共行。我在那里缺少什么?

diff awk text-processing uniq comm

25
推荐指数
1
解决办法
7万
查看次数

comm: 文件没有按顺序排列

我曾经comm比较两个排序的文件。这些文件中的每一行都是正整数。但结果显示

comm: file 1 is not in sorted order
comm: file 2 is not in sorted order
Run Code Online (Sandbox Code Playgroud)

即使这两个文件已排序,为什么会出现错误?

sort comm numeric-data

13
推荐指数
1
解决办法
1万
查看次数

使用 sort 和 comm 的问题

我试图找到两个纯数据文件的交集,从之前的帖子中发现可以通过

comm -12 <(sort test1.list) < (sort test2.list)
Run Code Online (Sandbox Code Playgroud)

在我看来,sort test1.list目的是按顺序对 test1.list 进行排序。为了了解sort工作原理,我尝试sort将以下文件 test1.list 作为sort test1.list > test2.list

100
-200
300
2
92
15
340
Run Code Online (Sandbox Code Playgroud)

然而,事实证明 test2.list 是

100
15
2
-200
300
340
92
Run Code Online (Sandbox Code Playgroud)

这个重新排序的列表让我很困惑这种排序是如何工作的,以及 sort 和 comm 是如何一起工作的。

linux shell sort comm

6
推荐指数
1
解决办法
3万
查看次数

RFCOMM 设备似乎丢失 (dev/rfcomm0)

我正在尝试通过蓝牙发送和接收串行命令。我已经安装了 pyBluez 库。问题是,虽然 rfcomm.conf 存在,但 /dev/ 目录中没有 rfcomm0。我重新启动但没有变化。

如果我运行以下命令,我会收到 Permission denied 错误。

sudo echo "This is a test" > /dev/rfcomm0
Run Code Online (Sandbox Code Playgroud)

为什么连接usb蓝牙模块后rfcomm没有自动添加到/dev?蓝牙模块兼容,我可以通过命令行扫描和查找设备。Bluez 和 bluez-utils 已经安装。

bluetooth comm bluez raspbian

5
推荐指数
1
解决办法
1万
查看次数

反转匹配行,NUL 分隔

我正在写一些处理文件匹配的东西,我需要一个反转操作。我有一个文件列表(例如 from find . -type f -print0 | sort -z >lst)和一个匹配列表(例如 from grep -z foo lst >matches– 请注意,这只是一个示例;matches可以是任何任意子集(包括空的或完整的)或lst),现在我想反转这个列表.

背景:我正在实现类似于find(1) 之类的东西,除了文件列表(尽管文件在调用时确实存在于文件系统中,但该列表可能已被预先过滤)。如果文件列表可能没有那么大,我可以使用find "${files[@]}" -maxdepth 0 -somecondition -print0,但即使适度使用我正在编写的内容也会超出 Linux 或 BSDargv大小限制。

如果这些行不是 NUL 分隔的,我可以使用comm -23 lst matches >inverted. 如果匹配不是 NUL 分隔的,我可以使用grep -Fvxzf matches lst. 但是,从我在第一段中提到的生成器来看,两者都是。

假设GNU工具安装,所以这种需求无法移植超越例如Debian的,因为我使用find -print0sort -z和朋友已经(虽然有些BSD系统有它,所以如果能在“更轻便”来完成,我不会抱怨) .

我正在尝试在这里进行代码重用;另外,comm -23除了它不支持更改输入行分隔符(尚)之外,它基本上已经是一个完美的工具,而且comm无论如何都是一个被低估且不够知名的工具。如果 Unix/Linux 工具箱没有提供任何合理的东西,我可能会comm -23在 shell 中重新实现一种形式(简化为这个用例),因为脚本已经(出于其他原因)需要一个恰好支持的 shell …

grep find files comm null

4
推荐指数
1
解决办法
99
查看次数

从两个文件中查找给定列中的公共元素并输出每个文件中的列值

我有两个带有制表符分隔值的文件,如下所示:

文件 1:

A    1
B    3
C    1
D    4
Run Code Online (Sandbox Code Playgroud)

文件2:

E    1
B    3
C    2
A    9
Run Code Online (Sandbox Code Playgroud)

我想在文件 1 和 2 之间找到第 1 列中的字符串相同的行,然后获取相应的值。所需的输出是一个看起来像这样的文件:

B    3    3
C    1    2
A    1    9
Run Code Online (Sandbox Code Playgroud)

这可以用 Unix one-liner 来完成吗?

awk comm join

3
推荐指数
1
解决办法
1万
查看次数

像“comm -3”这样的简单的逐行比较,但看起来像“diff -y”

我正在寻找一些东西,它为我提供了comm -3两个排序输出的输出(逐行比较,只有来自任一侧的附加/缺失行),但它看起来更像是来自 的输出diff -y,例如它使用整个宽度。

file1

bar/a
bar/feugiat
bar/libero
bar/mauris
bar/scelerisque
bar/urna
foo/blandit
foo/elementum
foo/feugiat
foo/laoreet
foo/luctus
foo/non
foo/pellentesque
foo/pulvinar
foo/rutrum
foo/sed
foo/ut
foo/vivamus
Run Code Online (Sandbox Code Playgroud)

file2

bar/a
bar/molestie
bar/quam
bar/risus
bar/tristique
foo/blandit
foo/elementum
foo/feugiat
foo/ligula
foo/massa
foo/mauris
foo/metus
foo/pellentesque
foo/pulvinar
foo/ut
Run Code Online (Sandbox Code Playgroud)

输出comm -3 file1 file2

bar/feugiat
bar/libero
bar/mauris
        bar/molestie
        bar/quam
        bar/risus
bar/scelerisque
        bar/tristique
bar/urna
foo/laoreet
        foo/ligula
foo/luctus
        foo/massa
        foo/mauris
        foo/metus
foo/non
foo/rutrum
foo/sed
foo/vivamus
Run Code Online (Sandbox Code Playgroud)

diff -y --suppress-common-lines file1 file2(GNU) 的输出,它取决于屏幕宽度:

bar/feugiat                                                   | bar/molestie …
Run Code Online (Sandbox Code Playgroud)

diff file-comparison comm text-formatting

3
推荐指数
1
解决办法
131
查看次数

我怎样才能以这种方式使用通讯?

根据我的理解,我想使用comm -23 file1 file2. file1 是 的结果find,file2 是cut -c43- list. 我是否可以将其写为 1 行而不使用任何文件(除了我命名的列表)?

bash comm

3
推荐指数
1
解决办法
2972
查看次数

bash 从两个文件中删除公共行

我有两个文件,(没有空行/空格/制表符)

/tmp/所有

aa  
bb  
cc  
hello  
SearchText.json  
xyz.txt  
Run Code Online (Sandbox Code Playgroud)

/tmp/必需

SearchText.json 
Run Code Online (Sandbox Code Playgroud)

我想要的最终输出是:(来自 /tmp/all 的所有不常见行)

aa  
bb  
cc  
hello  
xyz.txt 
Run Code Online (Sandbox Code Playgroud)

我尝试过以下命令:-

# comm -23 /tmp/required /tmp/all

SearchText.json
Run Code Online (Sandbox Code Playgroud)

# comm -23 /tmp/all /tmp/required

aa  
bb  
cc
hello  
SearchText.json  
xyz.txt  
Run Code Online (Sandbox Code Playgroud)

# comm -13 /tmp/all /tmp/required

SearchText.json  
Run Code Online (Sandbox Code Playgroud)

# comm -13 /tmp/required /tmp/all

aa  
bb  
cc  
hello  
SearchText.json  
xyz.txt  
Run Code Online (Sandbox Code Playgroud)

# grep -vf /tmp/all /tmp/required

# grep -vf /tmp/required /tmp/all

aa  
bb  
cc  
hello  
SearchText.json  
xyz.txt  
Run Code Online (Sandbox Code Playgroud)

# comm -23 <(sort /tmp/all) <(sort /tmp/required)

aa  
bb  
cc  
hello …
Run Code Online (Sandbox Code Playgroud)

diff text-processing comm

2
推荐指数
1
解决办法
2129
查看次数

Linux 相当于 windows cmd 命令

我要迁移到 Linux,我需要转换以下 Windowscmd命令:

fc file1.txt file2.txt | find /i "no se han encontrado diferencias" > nul && set equal=yes
Run Code Online (Sandbox Code Playgroud)

我觉得fc可以用diffor comm, findwith代替grep,但我不知道怎么做这&&部分,也许是一个if声明......

shell grep diff comm

1
推荐指数
1
解决办法
1531
查看次数