您的位置:首页 > 运维架构 > Shell

comm命令

2009-07-27 11:20 120 查看
今天在论坛看到帖子,才知道有这么个命令

,看来自己的知识太匮乏啊,为了让自己能记住一些,所以就查查资料,记录下来。

用法:comm [选项]... 文件1 文件2

逐行比较已排序的文件[文件1]和[文件2]。

With no options, produce three-column output. Column one contains

lines unique to FILE1, column two contains lines unique to FILE2,

and column three contains lines common to both files.

-1 suppress lines unique to FILE1

-2 suppress lines unique to FILE2

-3 suppress lines that appear in both files

--help 显示此帮助信息并退出

--version 输出版本信息并退出

请向 <bug-coreutils@gnu.org> 报告错误。

debian:/shell#

语  法:comm [-123][--help][--version][第1个文件][第2个文件]
补充说明:这项指令会一列列地比较两个已排序文件的差异,并将其结果显示出来,如果没有指定任何参数,则会把结果分成3行显示:第1行仅是在第1个
文件中出现过的列,第2行是仅在第2个文件中出现过的列,第3行则是在第1与第2个文件里都出现过的列。若给予的文件名称为"-",则comm指令会从标
准输入设备读取数据。
参  数:

-1 不显示只在第1个文件里出现过的列。

-2 不显示只在第2个文件里出现过的列。

-3 不显示只在第1和第2个文件里出现过的列。

--help 在线帮助。

--version 显示版本信息
debian:/shell# cat a1
1
2
3
4
5
6

debian:/shell# cat a2
1
2
3
4
7
8
debian:/shell# comm a1 a2
1
2
3
4
5
6

7
8
debian:/shell# comm -1 a1 a2
1
2
3
4
7
8
debian:/shell# comm -2 a1 a2
1
2
3
4
5
6

debian:/shell# comm -3 a1 a2
5
6

7
8
debian:/shell# comm -13 a1 a2
7
8
debian:/shell# comm -23 a1 a2
5
6

debian:/shell#

希望我不会遗忘!

debian:/shell# egrep -f a1 a2
1
2
3
4
debian:/shell# egrep -f a1 -v a2
7
8
debian:/shell# egrep -f a2 -v a1
5
6

debian:/shell#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  命令 linux shell 休闲 comm