在Linux中比较两个文件中的值[已关闭]

ktecyv1j  于 2023-02-11  发布在  Linux
关注(0)|答案(1)|浏览(101)

已关闭。此问题需要超过focused。当前不接受答案。
**想要改进此问题吗?**更新此问题,使其仅关注editing this post的一个问题。

7天前关闭。
Improve this question
有两个文件“file1”

33,601845322545,1,1,empty,1,1,,1,1,2023012800564,,417029789542123,4170245FFF63,18,**451**,,,,POPO,,
33,601837784521,1,1,empty,1,1,,1,1,2023012800333,,417029133211456,4170245C0F78,0,**3251**,,,,POPO,,
33,601864453218,1,1,empty,1,1,,1,1,2023012800307,,417029445521368,41702558AED4,4,**124**,,,,POPO,,
33,601822145638,1,1,empty,1,1,,1,1,2023012800452,,417029132654852,4170261F3C01,8,**1478**,,,,POPO,,
33,601847856326,1,1,empty,1,1,,1,1,2023012800888,,417029452169785,41702485E296,6,**654**,,,,POPO,,
33,601887962132,1,1,empty,1,1,,1,1,2023012800489,,417029964537412,4170221AAA45,12,**6328**,,,,POPO,,
33,601865432198,1,1,empty,1,1,,1,1,2023012800307,,417029145189234,41702920DE23,0,**541**,,,,POPO,,

“文件2”

33,601835841985,1,1,empty,1,1,,1,1,2023012800448,,417029652301595,4170245FC985,5,**4515**,,,,POPO,,
33,601837784521,1,1,empty,1,1,,1,1,2023012800333,,417029133211456,4170245C0F78,0,**3251**,,,,POPO,,  
33,601864453218,1,1,empty,1,1,,1,1,2023012800307,,417029445521368,41702558AED4,4,**124**,,,,POPO,,  
33,601812546872,1,1,empty,1,1,,1,1,2023012800630,,417029887412639,41702012AC87,81,**147**,,,,POPO,,
33,601847856326,1,1,empty,1,1,,1,1,2023012800888,,417029452169785,41702485E296,6,**654**,,,,POPO,,   
33,601831458795,1,1,empty,1,1,,1,1,2023012800872,,417029632078564,4170280FE453,1,**632**,,,,POPO,,
33,601878103569,1,1,empty,1,1,,1,1,2023012800651,,417029655221892,41702446FF09,0,**5416**,,,,POPO,,

我需要一个脚本来比较“file1”中的每个粗体值与“file2”中的粗体值,如果“file1”中的值在“file2”中不存在,则打印此值所在的行
我试着用鹰

atmip9wb

atmip9wb1#

我认为这种方法可能会帮助你实现你想要的。
第一件事是cutdelimitewith***"",每个字段并选择需要比较的字段16*,然后将输出传递给diff命令。
diff <(cut -f16 -d "," file1) <(cut -f16 -d "," file2)
您将得到这样的输出,但根据您的shell使用花哨的颜色。

➜  tmp diff <(cut -f16 -d "," file1) <(cut -f16 -d "," file2)
1,3c1,3
< 451
< 451
< 3251
---
> 4515
> 632
> 5416

相关问题