Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 用于比较两个以900 x 900逗号分隔的大型文件的脚本_Linux_Bash_Awk - Fatal编程技术网

Linux 用于比较两个以900 x 900逗号分隔的大型文件的脚本

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的最简单方法,不考虑字段内的

我尝试过awk,但无法在两个文件上同时对每个单元格1执行差异。我尝试过awk,但无法在两个文件上同时对每个单元格1执行差异。我尝试过awk,但无法在两个文件上一次对每个单元格1执行差异。如果您只是想要一个粗略的答案,可能最简单的方法是执行以下操作:

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