我正在寻找一种方法列出第二个文件中不存在于第一个文件中的数字
我已经尝试了各种方法:
comm (getting some weird sorting errors) fgrep -v -x -f second-file.txt first-file.txt (unsure of the result,there should be more)
谢谢
在PowerShell中使用compare-object函数时,可以从多个csv文件的列中获取信息吗?
_stricmp在string匹配时返回错误的值。 该怎么办?
为linux内核创build补丁文件
Windows应用程序的性能分析。 Visual Studio Profiler更好的select?
用于创build文件/文件夹级补丁(包括二进制文件)的两个目录树的差异
如果“14”LEQ“7”()失败
grep -Fxv -f first-file.txt second-file.txt
基本上查找second-file.txt所有行,它们不匹配first-file.txt中的任何行。 如果文件很大,可能会变慢。
此外,一旦你排序文件(使用sort -n如果他们是数字),那么comm也应该工作。 它给了什么错误? 尝试这个:
comm -23 second-file-sorted.txt first-file-sorted.txt
你需要使用comm :
comm -13 first.txt second.txt
会做这项工作。
也可能需要在以下文件中进行排序:
comm -13 <(sort first.txt) <(sort second.txt)
如果文件是数字加-n选项进行sort 。
这应该工作
comm -13 <(sort file1) <(sort file2)
看起来排序-n(数字)不能与comm,它使用内部排序(字母数字)
f1.txt
1 2 21 50
f2.txt
1 3 21 50
21应该出现在第三栏
#WRONG $ comm <(sort -n f1.txt) <(sort -n f2.txt) 1 2 21 3 21 50 #OK $ comm <(sort f1.txt) <(sort f2.txt) 1 2 21 3 50
cat f1.txt f2.txt | sort |uniq > file3
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。