linux comm命令_在Linux中使用Comm命令比较文件

linux comm命令

linux comm命令

Linux have a lot of tools to compare files. These tools provides a lot of powerful features to meet user needs. But sometimes just simple comparison is enough for some users. comm is a tool for this purpose . Comm only compare files and shows differences in a visual manner.

Linux有很多工具可以比较文件。 这些工具提供了许多强大的功能来满足用户需求。 但是有时候,对于某些用户而言,简单的比较就足够了。 comm是用于此目的的工具。 Comm仅比较文件并以可视方式显示差异。

句法 (Syntax)

We will use following syntax for comm command.

我们将对comm命令使用以下语法。

comm [OPTION]... FILE1 FILE2

帮帮我 (Help)

$ comm --help
Help
Help
帮帮我

相比(Compare)

We will simply compare two files those have same and different lines. We just need to provide file names to the comm command. Here is our files.

我们将简单比较两个具有相同和不同行的文件。 我们只需要为comm命令提供文件名即可。 这是我们的文件。

a.txt (a.txt)

test 
pof 
apple 
banana

b.txt (b.txt)

test 
ok 
apple 
banana 
lemon

Now we issue the command like below.

现在,我们发出如下命令。

$ comm a.txt b.txt
Compare
Compare
相比

As we can see the differences ok and lemon are printed in required column.

正如我们所看到的,“ ok和“ lemon的区别被打印在必填列中。

检查订单 (Check Order)

In previous example we see that there are some information about unsorted columns. comm command automatically checks the order of the provided text file. This can be disabled with --nocheck-order parameter.

在前面的示例中,我们看到一些有关未排序列的信息。 comm命令自动检查提供的文本文件的顺序。 可以使用--nocheck-order参数禁用此功能。

$ comm --nocheck-order a.txt b.txt
Do Check Order
Do Check Order
检查订单

抑制列(Suppress Columns)

Columns can be suppressed with the suppress feature. We just need to provide column number to suppress like -1 , -2 , -3

可以使用抑制功能抑制列。 我们只需要提供列号来抑制-1-2-3

  •  -1              suppress column 1 (lines unique to FILE1)

    -1抑制列1(FILE1独有的行)
  • -2              suppress column 2 (lines unique to FILE2)

    -2取消第2列(FILE2独有的行)
  • -3              suppress column 3 (lines that appear in both files)

    -3取消第3列(两个文件中均显示行)
$ comm -1 a.txt b.txt
Suppress Columns
Suppress Columns
抑制列
LEARN MORE  How To Use windiff To Compare Contents Of Two Files In Windows with Examples?
了解更多信息如何使用windiff在Windows中通过示例比较两个文件的内容?

翻译自: https://www.poftut.com/compare-files-comm-command-linux/

linux comm命令

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值