Linux 用于比较两个以900 x 900逗号分隔的大型文件的脚本
我尝试过awk,但无法在两个文件上同时对每个单元格1执行差异。我尝试过awk,但无法在两个文件上同时对每个单元格1执行差异。我尝试过awk,但无法在两个文件上一次对每个单元格1执行差异。如果您只是想要一个粗略的答案,可能最简单的方法是执行以下操作:Linux 用于比较两个以900 x 900逗号分隔的大型文件的脚本,linux,bash,awk,Linux,Bash,Awk,我尝试过awk,但无法在两个文件上同时对每个单元格1执行差异。我尝试过awk,但无法在两个文件上同时对每个单元格1执行差异。我尝试过awk,但无法在两个文件上一次对每个单元格1执行差异。如果您只是想要一个粗略的答案,可能最简单的方法是执行以下操作: tr , \\n file1 > /tmp/output tr , \\n file2 | diff - /tmp/output 这将把每个文件转换为一列并运行diff。您可以计算与输出行号不同的单元格 使用awk的最简单方法,不考虑字段内的
tr , \\n file1 > /tmp/output
tr , \\n file2 | diff - /tmp/output
这将把每个文件转换为一列并运行diff。您可以计算与输出行号不同的单元格 使用awk的最简单方法,不考虑字段内的换行符、引号等 打印相同的
awk 'BEGIN{RS=",|"RS}a[FNR]==$0;{a[NR]=$0}' file{,2}
打印差异
awk 'BEGIN{RS=",|"RS}FNR!=NR&&a[FNR]!=$0;{a[NR]=$0}' file{,2}
打印相同或不同的内容
awk 'BEGIN{RS=",|"RS}FNR!=NR{print "cell"FNR (a[FNR]==$0?"":" not")" the same"}{a[NR]=$0}' file{,2}
cell1 the same
cell2 the same
cell3 the same
cell4 the same
cell5 the same
cell6 not the same
cell7 the same
cell8 not the same
cell9 the same
cell10 not the same
cell11 not the same
cell12 not the same
cell13 not the same
cell14 not the same
cell15 not the same
输入 文件 文件2
输出 同样的 不同的
2
1
12
1
1
1
1
12
相同不同
awk 'BEGIN{RS=",|"RS}FNR!=NR{print "cell"FNR (a[FNR]==$0?"":" not")" the same"}{a[NR]=$0}' file{,2}
cell1 the same
cell2 the same
cell3 the same
cell4 the same
cell5 the same
cell6 not the same
cell7 the same
cell8 not the same
cell9 the same
cell10 not the same
cell11 not the same
cell12 not the same
cell13 not the same
cell14 not the same
cell15 not the same
请您的问题为我们提供一个示例,说明您的输入是什么样的(示例不必是900x900)以及您的目标是什么。如果你已经尝试过,也包括在内。
cell1 the same
cell2 the same
cell3 the same
cell4 the same
cell5 the same
cell6 not the same
cell7 the same
cell8 not the same
cell9 the same
cell10 not the same
cell11 not the same
cell12 not the same
cell13 not the same
cell14 not the same
cell15 not the same