linux shell comm命令的使用
2015-01-22 15:36
99 查看
comm是文件比较的命令,主要用于比较已经排序的文件
comm对输入的两个文件进行比较,输出3列数据,分别是1>仅在file1中出现的行2>仅在file2中出现的行3>在两个文件中都存在的行。
假如有文件1.txt, 2.txt如下所示
1.txt
1 1 10
2 2 20
3 3 30
2.txt
1 1 10
2 2 10
3 3 30
5 5 50
使用命令comm -1 -2 1.txt 2.txt,结果为显示交集
1 1 10
3 3 30
使用命令comm -2 -3 1.txt 2.txt,结果为显示只有1特有数据
2 2 20
使用命令comm -1 -3 1.txt 2.txt,结果为显示只有2特有数据
2 2 10
5 5 50
comm对输入的两个文件进行比较,输出3列数据,分别是1>仅在file1中出现的行2>仅在file2中出现的行3>在两个文件中都存在的行。
假如有文件1.txt, 2.txt如下所示
1.txt
1 1 10
2 2 20
3 3 30
2.txt
1 1 10
2 2 10
3 3 30
5 5 50
使用命令comm -1 -2 1.txt 2.txt,结果为显示交集
1 1 10
3 3 30
使用命令comm -2 -3 1.txt 2.txt,结果为显示只有1特有数据
2 2 20
使用命令comm -1 -3 1.txt 2.txt,结果为显示只有2特有数据
2 2 10
5 5 50
相关文章推荐
- linux shell - 命令使用
- 使用Bash编写Linux Shell脚本-7.复合命令
- linux shell 管道命令(pipe)使用及与shell重定向区别
- Linux Shell下使用vi编辑器命令大全
- Linux Shell脚本编程--nc命令使用详解
- Linux Shell下使用vi编辑器命令
- linux shell脚本学习xargs命令使用详解
- Linux Shell下使用vi编辑器命令
- 使用bash编写Linux shell脚本--复合命令
- 8 个使用的Linux shell 命令
- Linux Shell脚本ldd命令原理及使用方法
- 使用source与点命令执行Linux shell脚本的体会
- 使用Bash编写Linux Shell脚本-7.复合命令
- 在windows环境下使用常用的linux shell 命令
- 在linux shell中使用ftp命令来实现自动登陆、上传与下载
- 《linux核心应用命令速查》连载二:lastcomm:显示以前使用过的命令的信息
- lastcomm:显示以前使用过的命令的信息
- Astyle及linux shell rm命令的使用技巧
- linux shell 管道命令(pipe)使用及与shell重定向区别
- linux shell脚本学习xargs命令使用详解