最后,我的代码中不断出现解析错误
C:\Users\user\Documents\hafwork\hafLatest\CRM>AWK.EXE -f testking123.awk sample.txt
awk: testking123.awk:85: END{
awk: testking123.awk:85: ^ parse error
awk: testking123.awk:90:
awk: testking123.awk:90: ^ parse error
这是我的代码:
BEGIN{
FS= "|"
countA=CountB=0;
}
{
id=substr($2,1,1);
++file[id]
if ($3 == "P")
{
if(countB==0){
for(dupes in B)
print B[dupes] > "Bdupes.txt"
}
else if(countA==0){
for(dupes in A)
print A[dupes] > "Adupes.txt"
}
else if(countA==countB)
i=1
while(i<countA){
printA[i] > "mixdupes.txt"
printB[i] > "mixdupes.txt"
}
if(A<B && A!=0){
i=1
while(i<(A+1)){
printA[i] > "mixdupes.txt"
printB[i] > "mixdupes.txt"
}
i=A+1
while(i<(B+1)){
print B[i]> "Bdupes.txt"
if(id=="A"){
A[1]=$0
countA=1;
countB=0;
}
else if (id=="B"){
B[1]=$0
countA=0;
countB=1;
}
}
elseif ($3 == "C")
{
if(id=="A"){
countA++;
A[countA]=$0
}
else if(id=="B"){
countB++;
B[countB]=$0
}
}
}
END{
for (file_id in file)
print file_id ":", file[file_id]
}
谁能告诉我这是为什么?我试过删除空格等。我不确定它是否与脚本的结尾有关,或者脚本中是否有问题。对 AWK 来说很新,所以不能 100% 确定它。TIA