Shell命令查找两个文件中的公共行 [英] Shell command to find lines common in two files

查看:29
本文介绍了Shell命令查找两个文件中的公共行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定我曾经找到一个 shell 命令,它可以打印两个或多个文件中的公共行.它叫什么名字?

I'm sure I once found a shell command which could print the common lines from two or more files. What is its name?

它比 diff 简单得多.

It was much simpler than diff.

推荐答案

您正在寻找的命令是 comm.例如:-

The command you are seeking is comm. eg:-

comm -12 1.sorted.txt 2.sorted.txt

这里:

-1 : 抑制第 1 列(1.sorted.txt 独有的行)

-1 : suppress column 1 (lines unique to 1.sorted.txt)

-2 : 抑制第 2 列(2.sorted.txt 独有的行)

-2 : suppress column 2 (lines unique to 2.sorted.txt)

这篇关于Shell命令查找两个文件中的公共行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆