Error[8]: Undefined offset: 47, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述介绍《LINUX实 *** :Linux comm命令求出文件的交集、差集》开发教程,希望对您有用。

《liNUX实 *** :linux comm命令求出文件的交集、差集》要点:
本文介绍了liNUX实 *** :linux comm命令求出文件的交集、差集,希望对您有用。如果有疑问,可以联系我们。

A(1,2,3)和B(3,4,5),A和B的交集是3,A对B的差集是1和2,B对A的差集是4和5,A和B求差的成果是1、2、4、5.

在linux中可以使用comm敕令求出这些集.

[root@linuxIDc tmp]# cat <<eof>set1.txt> orange> gold> apple> sliver> steel> iron> eof
 
[root@linuxIDc tmp]# cat <<eof>set2.txt> orange> gold> cookiee> carrot> eof

使用comm敕令.

[root@linuxIDc tmp]# comm set1.txt set2.txtapple                orangecomm: file 1 is not in sorted ordercomm: file 2 is not in sorted order                gold        cookiee        carrotsilversteeliron

提示没有排序,所以comm必须要保证比拟的文件是有序的.

[root@linuxIDc tmp]# sort set1.txt -o set1.txt;sort set2.txt -o set2.txt
[root@linuxIDc tmp]# comm set1.txt set2.txt                             apple        carrot        cookiee                goldiron                orangesilversteel

成果中输出了3列,每一列使用制表符\t隔开.第一列是set1.txt中有而set2.txt中没有的,第二列则是set2.txt中有而set1.txt中没有的,第三列是set1.txt和set2.txt中都有的.

依据这三列就可以求出交集、差集和求差.

交集便是第三列.使用-1和-2分别删除第一第二列便是第三列的结果.

[root@linuxIDc tmp]# comm set1.txt set2.txt -1 -2goldorange

A对B的差集便是第一列,B对A的差集便是第二列.

[root@linuxIDc tmp]# comm set1.txt set2.txt  -2 -3  # A对B的差集appleironsilversteel
[root@linuxIDc tmp]# comm set1.txt set2.txt  -1 -3   # B对A的差集carrotcookiee

A和B的求差便是第一列和第二列的组合.

[root@linuxIDc tmp]# comm set1.txt set2.txt  -3  apple        carrot        cookieeironsilversteel

但是这样分两列的结果不便利查看,应该进行处理使它们显示在同一列上.

[root@linuxIDc tmp]# comm set1.txt set2.txt  -3 | tr "\t" ""applecarrotcookieeironsilversteel本文永远更新链接地址

[+++]:

《liNUX实 *** :linux comm命令求出文件的交集、差集》是否对您有启发,欢迎查看更多与《liNUX实 *** :linux comm命令求出文件的交集、差集》相关教程,学精学透。内存溢出PHP学院为您提供精彩教程。

总结

以上是内存溢出为你收集整理的LINUX实 *** :Linux comm命令求出文件的交集、差集全部内容,希望文章能够帮你解决LINUX实 *** :Linux comm命令求出文件的交集、差集所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
LINUX实 *** :Linux comm命令求出文件的交集、差集_系统运维_内存溢出

LINUX实 *** :Linux comm命令求出文件的交集、差集

LINUX实 *** :Linux comm命令求出文件的交集、差集,第1张

概述介绍《LINUX实 *** :Linux comm命令求出文件的交集、差集》开发教程,希望对您有用。

《liNUX实 *** :linux comm命令求出文件的交集、差集》要点:
本文介绍了liNUX实 *** :linux comm命令求出文件的交集、差集,希望对您有用。如果有疑问,可以联系我们。

A(1,2,3)和B(3,4,5),A和B的交集是3,A对B的差集是1和2,B对A的差集是4和5,A和B求差的成果是1、2、4、5.

在linux中可以使用comm敕令求出这些集.

[root@linuxIDc tmp]# cat <<eof>set1.txt> orange> gold> apple> sliver> steel> iron> eof
 
[root@linuxIDc tmp]# cat <<eof>set2.txt> orange> gold> cookiee> carrot> eof

使用comm敕令.

[root@linuxIDc tmp]# comm set1.txt set2.txtapple                orangecomm: file 1 is not in sorted ordercomm: file 2 is not in sorted order                gold        cookiee        carrotsilversteeliron

提示没有排序,所以comm必须要保证比拟的文件是有序的.

[root@linuxIDc tmp]# sort set1.txt -o set1.txt;sort set2.txt -o set2.txt
[root@linuxIDc tmp]# comm set1.txt set2.txt                             apple        carrot        cookiee                goldiron                orangesilversteel

成果中输出了3列,每一列使用制表符\t隔开.第一列是set1.txt中有而set2.txt中没有的,第二列则是set2.txt中有而set1.txt中没有的,第三列是set1.txt和set2.txt中都有的.

依据这三列就可以求出交集、差集和求差.

交集便是第三列.使用-1和-2分别删除第一第二列便是第三列的结果.

[root@linuxIDc tmp]# comm set1.txt set2.txt -1 -2goldorange

A对B的差集便是第一列,B对A的差集便是第二列.

[root@linuxIDc tmp]# comm set1.txt set2.txt  -2 -3  # A对B的差集appleironsilversteel
[root@linuxIDc tmp]# comm set1.txt set2.txt  -1 -3   # B对A的差集carrotcookiee

A和B的求差便是第一列和第二列的组合.

[root@linuxIDc tmp]# comm set1.txt set2.txt  -3  apple        carrot        cookieeironsilversteel

但是这样分两列的结果不便利查看,应该进行处理使它们显示在同一列上.

[root@linuxIDc tmp]# comm set1.txt set2.txt  -3 | tr "\t" ""applecarrotcookieeironsilversteel本文永远更新链接地址

《liNUX实 *** :linux comm命令求出文件的交集、差集》是否对您有启发,欢迎查看更多与《liNUX实 *** :linux comm命令求出文件的交集、差集》相关教程,学精学透。内存溢出PHP学院为您提供精彩教程。

总结

以上是内存溢出为你收集整理的LINUX实 *** :Linux comm命令求出文件的交集、差集全部内容,希望文章能够帮你解决LINUX实 *** :Linux comm命令求出文件的交集、差集所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1042209.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存